HYPER-V RESUME REPLICATION SCRIPT

Some time the hyper-v replication get in to suspended mode or halt on any other reason, here is a Powershell script to run from the replica server which will start the replication again :

 

$ReplicationData = Get-VMReplication 

Foreach ($VMReplica in $ReplicationData) {
    Write-Host "Starting Replication on" $VMReplica.Name
    Do{
        If ($VMReplica.Health -eq "Suspended" -Or $VMReplica.Health -eq "Critical" -or $VMReplica.Health -eq "Warning") {
            Write-Host "VM Replication is in Critical Error State and suspended, Suspend and resuming Replication that is:" $VMReplica.State
            Suspend-VMReplication -ComputerName $VMReplica.ReplicaServer -VMName $VMReplica.Name
            Suspend-VMReplication -ComputerName $VMReplica.PrimaryServer -VMName $VMReplica.Name
            Resume-VMReplication -ComputerName $VMReplica.ReplicaServer -VMName $VMReplica.Name
            Resume-VMReplication -ComputerName $VMReplica.PrimaryServer -VMName $VMReplica.Name
            start-sleep -s 20
       }
       }
   Until($VMReplicaHealth.Health -notcontains "Normal")
}

Leave a Reply

Your email address will not be published.