HyperVCheckpoints.ps1

Wrote a simple PowerShell script today for one of my lab environments that safely reboots all virtual machines under a local Hyper-V host, and upon restart, creates a new checkpoint. The script is best used on a scheduled basis, i.e; using Task Scheduler. I have the script running every night at 0300.

While scheduled reboots may seem risky to some, I believe the opposite; risk is mitigated with the practice. Depending on your scheduled time windows, this gives administrators the ability to identify/resolve issues with a rebooting server, as opposed to the issue appearing during primary operational hours, resulting in downtime.

A few caveats:

  • Checkpoints are generally not recommended in a production environment (see https://hyperv.veeam.com/blog/what-are-hyper-v-snapshots-12-things-to-know/) and are definitely not a replacement for full backups.
  • The script, by default, restarts all VMs under the local Hyper-V host. If you have VMs that you do not wish to be restarted/have checkpoints taken, use the ExemptVMNames parameter to specify said VMs.

 

Script can be found on my github:

https://github.com/mehlsec/HyperVCheckpoints