How to create a PowerShell script to shut down, export, and start each VM, then to copy the export to the opposite Hyper-V R2?

Mar 7, 2011 at 3:51 PM

Dear Sir,

I have two Windows Server 2008 R2 Hyper-V Servers with SP1.
I need to ensure that I can restore virtual machines (VMs) in the event of a Hardware failure.
I am using one server at the moment and the second one is standby in case of failure.

The answer is:
Use a PowerShell script to shut down, export, and start each VM, and then to copy the export to the opposite 2nd Hyper-V server. Run the script once per day on each Hyper-V Server...

My question is:
Could someone please help me to create above script under powershell on my current online Hyper-V Server to shut down, export, and start each VM, and then to copy the export to the opposite 2nd Hyper-V server?
Then I will add the script to Task Scheduler to run once per day after working hours.

I never worked before to create powershell scripts... 
I need the full syntax.

Thank You.

Feb 10, 2012 at 10:07 PM

I wrote a script for this you may be interested in. You can find it here: http://www.czerno.com/html/windows/hyperv/cluster/HyperV_Export_VMs.asp

Feb 11, 2012 at 4:17 PM

Look previous post

http://pshyperv.codeplex.com/discussions/272206

and schedule copy ;)