Looking at Replica Delta in Hyper-V with PowerShell

If you have used Hyper-V Replica, you will know about the replica status column.  This is the part of the user interface where we tell you what the state of replica is: normal, warning or critical.  A simple interpretation of these states is:

  • Normal: everything is fine, nothing to worry about.
  • Warning: there have been some problems, but we think we can fix them for you.
  • Critical: things have gone past the point where we can fix them, you need to intervene.

On issue that I have encountered with my home configuration is that there is that there can be a wide variance in the “warning” state.  To help me to better understand what is going on with a virtual machine that is in the “warning” state I like to see how far behind the replica virtual machine is from the primary virtual machine.

You can do this quite easily through the user interface by bringing up the Hyper-V Replica health report for a single virtual machine.  But there is no easy way to do this for multiple virtual machines at once, that is unless you use PowerShell!

Here is a little one-liner that I put together that will show you the current replication delta for all your virtual machines:

get-vm | Get-VMReplication | select name, replicationmode, replicationhealth,  @{Expression={"{0:N0}" -f ((get-date)-($_.lastreplicationtime)).TotalMinutes};Label="Delta (min)"}

Which looks like this when run:


Note – this screenshot comes from after I needed to change a disk in one of my systems, and then resync the virtual machines.  At this point in time all virtual machines have resynced except for my file server.