Recently we enabled Hyper-V Replica between two of our Windows Server 2012 R2 Datacenter Clusters.
In the first days I was checking the replication of theVMs manually using a PowerShell one-liner.
Eventually I got tired of that, so I searched a little bit and found a PS Script (not sure where) and customized it to fit my needs.
When executed on one Cluster Node (could also be a standalone machine), the script gathers information regarding the replication and sends it via Mail to me:
In order to automate the sending of the report, I created a scheduled task on one Cluster Node, following the settings:
- Name: ReplicaMail
- User: replica (restricted service user)
- Run whether user is logged on or not
- Run with highest privileges
- Configure for: Windows Server 2012 R2
- Run Daily
- Stop task if running longer than 3min
- Start a program:
- Program: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
- Arguments: .\MailRepHealth.ps1 -to email@example.com -from firstname.lastname@example.org -smtpserver xxx.xxx.xxx.xxx -hostorclustername clustername -iscluster
- Start in: C:\tmp\ (this is the location of the script)
Now this is pretty much all the configuration needed to do, except saving the script on your server. Here it is (please save it in .ps1 format:
Please note that I’m not responsible for any issues caused by running PowerShell scripts on your systems.
Read the script, make sure you test it and you are ready to use it.