Created
November 11, 2020 02:44
-
-
Save the-takeo/5c51c63c60ced2006550c6a137fe191c to your computer and use it in GitHub Desktop.
VMResumeReplication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$HostServers=@("HostSvr1","HostSvr2","HostSvr3","HostSvr4","HostSvr5") | |
foreach($HostServer in $HostServers){ | |
Get-vm -ComputerName $HostServer | Where-Object {$_.ReplicationHealth -ne "NotApplicable"} | Where-Object {$_.ReplicationHealth -ne "Normal"} | ForEach-Object{ | |
$attempts=3 | |
$sleepInSeconds=60 | |
do | |
{ | |
try | |
{ | |
echo $_.Name | |
Resume-VMReplication -VMName $_.Name -ComputerName $HostServer; | |
} | |
catch [Exception] | |
{ | |
Write-Host $_.Exception.Message | |
} | |
$attempts-- | |
if ($attempts -gt 0) { sleep $sleepInSeconds } | |
} while ($attempts -gt 0) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment