Skip to content

Instantly share code, notes, and snippets.

@the-takeo
Created November 11, 2020 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the-takeo/5c51c63c60ced2006550c6a137fe191c to your computer and use it in GitHub Desktop.
Save the-takeo/5c51c63c60ced2006550c6a137fe191c to your computer and use it in GitHub Desktop.
VMResumeReplication
$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