I had a problem where the server that was holding some hyper-v replicas had some corruption. Some vm’s were able to resume replication but others were marked as needing resynchronisation. This is a process you can either do manually one by one or write a simple two line powershell command to resync all vm’s on one host to another. However the problem is the command runs async (eg without waiting) and so all vm’s will be triggered at the same time causing huge IO.
Suspend-VMReplication -VMName "vm1"
Resume-VMReplication -VMName "vm1" -Resynchronize
you could add a parameter which sets the schedule for the resynchronisation but i wrote this small powershell script to resync all vm’s on one host (regardless of it needing a resync or not).
$vms = get-vm
foreach ($vm in $vms)
{
# echo "checking $vm.name"
Write-host ("vm: {0}" -f $vm.name)
Write-host ("state: {0}" -f $vm.replicationstate)
#echo "replicationstate $vm.replicationstate"
if ($vm.replicationstate -ne "disabled")
{
Write-host ("suspending replication on vm: {0}" -f $vm.name)
# echo "suspending $vm.name"
$vm | Suspend-VMReplication
# echo "suspending $vm.name.tostring()"
$vm | Resume-VMReplication -Resynchronize
Write-host ("resynchronizing replication on vm: {0}" -f $vm.name)
#echo "resynchronizing $vm.name.tostring()"
Start-Sleep 5
#wait until replication starts.
$count =0
while ($vm.replicationstate -eq "Resynchronizing" )
{
$count ++
Start-Sleep -s 1
}
Write-host ("resynchronizing replication on vm {0} took: {1} seconds" -f $vm.name, $count )
}
}