Powershell Script to Shutdown and Export Hyper-V VMs, one at a time, for Windows Server 2008 R2.

by Stan Czerno July 21, 2011 13:17 CST

The script requires the PowerShell Management Library for Hyper-V for it to work. The PowerShell Management Library for Hyper-V can be downloaded at http://pshyperv.codeplex.com/

Be sure to read the documentation before using:

http://pshyperv.codeplex.com/releases/view/62842

http://pshyperv.codeplex.com/releases/view/38769

This is how I backup the VMs on my Two-Node Hyper-V Cluster. I can afford for my servers to be down while this is done and some of my other resources are clustered so there is minimum down time.I also do System State Backups, Exchange Backups and SQL Backups in addition.

This script can be used on a Stand-Alone Hyper-V Server as well.

Let me know what you think about the script and if you have a better way of doing this.

 http://www.czerno.com/default.asp?inc=/html/windows/hyperv/cluster/HyperV_Export_VMs.asp

Tags: ,

Catergories: Windows | HyperV | Powershell

Comments (6) -

Stan Czerno United States
July 28, 2011 08:50 CST

I made a few changes to the script. One of my VMs intergrated services were not responding so the machine could not be shutdown.

I added a HeartBeat check to the script as well as to determine if the VM is already stopped.

Sean Sweeney United States
January 14, 2013 10:23 CST

This script is EXACTLY what I was looking to do.  Thank you!  

Marcus Yin Singapore
March 16, 2013 00:41 CST

Hi,

How do i set dynamics $dest?

$dest = "H:\HyperV"

Example
H:\HyperV\16032013\

16032013 - date of backup

Thank you.

Marcus

Stan Czerno United States
March 16, 2013 02:54 CST

$GetDate = Get-Date -format "yyyyMMMd"
$Dest = "H:\HyperV\$GetDate"

Marcus Yin Singapore
March 17, 2013 18:06 CST

Nice!

Thanks

Marcus

Jed Wilson
January 16, 2015 10:53 CST

Can this be changed to specify the name of the VM you want to backup rather than backing up all of the VMs running on the physical host?

Thanks,
Jed

Comments are closed