Prompt for credentials for remote replication
This commit is contained in:
17
certy.ps1
17
certy.ps1
@@ -238,6 +238,7 @@ function Invoke-Replication {
|
||||
[string[]]$Servers,
|
||||
[string]$Command,
|
||||
[bool]$UseRemote,
|
||||
[pscredential]$Credential,
|
||||
[scriptblock]$Log
|
||||
)
|
||||
|
||||
@@ -261,7 +262,11 @@ function Invoke-Replication {
|
||||
if ($UseRemote) {
|
||||
if (-not $sessions.ContainsKey($server)) {
|
||||
try {
|
||||
$sessions[$server] = New-PSSession -ComputerName $server -ErrorAction Stop
|
||||
if ($Credential) {
|
||||
$sessions[$server] = New-PSSession -ComputerName $server -Credential $Credential -ErrorAction Stop
|
||||
} else {
|
||||
$sessions[$server] = New-PSSession -ComputerName $server -ErrorAction Stop
|
||||
}
|
||||
& $Log "Replication session opened: $server"
|
||||
} catch {
|
||||
& $Log ("Replication session error on {0}: {1}" -f $server, $_.Exception.Message)
|
||||
@@ -1132,7 +1137,15 @@ $runBtn.Add_Click({
|
||||
& $logAction "Replication targets empty; using primary DNS server $dnsServer."
|
||||
}
|
||||
}
|
||||
Invoke-Replication -Servers $replicationTargets -Command $replicationCmdBox.Text -UseRemote $replicationRemoteBox.Checked -Log $logAction
|
||||
$replicationCredential = $null
|
||||
if ($replicationRemoteBox.Checked) {
|
||||
$replicationCredential = Get-Credential -Message "Enter credentials for replication targets."
|
||||
if (-not $replicationCredential) {
|
||||
& $logAction "Replication canceled: credentials not provided."
|
||||
return
|
||||
}
|
||||
}
|
||||
Invoke-Replication -Servers $replicationTargets -Command $replicationCmdBox.Text -UseRemote $replicationRemoteBox.Checked -Credential $replicationCredential -Log $logAction
|
||||
if ($replicationDelaySeconds -gt 0) {
|
||||
& $logAction "Waiting $replicationDelaySeconds seconds for replication."
|
||||
Start-Sleep -Seconds $replicationDelaySeconds
|
||||
|
||||
Reference in New Issue
Block a user