The following script will finish successfully, but after failover, the new DestinationComputer data volume still in mount state and the Replication status is "WaitingForDestination"
$cred = Get-Credential domain\adminaccount
$s = New-PSSession -computerName DestinationSrv01 -credential $cred
Invoke-Command -Session $s -Scriptblock {Set-SRPartnership -NewSourceComputerName DestinationSrv01 -SourceRGName rg02 -DestinationComputerName SourceSrv01 -DestinationRGName rg01 -confirm:$false}
Remove-PSSession $s
SourceSrv01:
DataVolume IsMounted ReplicationMode ReplicationStatus
---------- --------- --------------- -----------------
D:\ Synchronous WaitingForDestination
I tested the same command using Enter-PSSession
, the result is the same as above.
If I RDP to DestinationSrv01 and open PowerShell console run the following command, every is working.
Set-SRPartnership -NewSourceComputerName DestinationSrv01 -SourceRGName rg02 -DestinationComputerName SourceSrv01 -DestinationRGName rg01 -confirm:$false
SourceSrv01:
DataVolume IsMounted ReplicationMode ReplicationStatus
---------- --------- --------------- -----------------
D:\ False Synchronous ContinuouslyReplicating
I'm navigating blind here but with current comments and the suspicion of a timing issue try adjusting the position of Start-Sleep
:
$cred = Get-Credential domain\adminaccount
$s = New-PSSession -computerName DestinationSrv01 -credential $cred
$ScriptBlock = {
$SRPartnerShip = Set-SRPartnership -NewSourceComputerName DestinationSrv01 -SourceRGName rg02 -DestinationComputerName SourceSrv01 -DestinationRGName rg01 -confirm:$false
Start-Sleep -Seconds 30
$SRPartnerShip = $SRPartnerShip | Get-SRPartnership
}
Invoke-Command -Session $s -Scriptblock $ScriptBlock
Remove-PSSession $s
This waits 30 seconds before refreshing then returning. The way you had it you were waiting 30 seconds after the return. If the refresh via a simple re-get didn't fix it it wouldn't change anything except to wait longer to return bad info.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.