Hyper-V Lab setup

SteveDot
SteveDot used Ask the Experts™
on
I have five 2008 R2 machines that each have a XP,Vista x86, Vista x64, Win7 x86 and Win7 x64 guest operating systems.

What I can't seem to figure out is a good way to every night restore the machines back to how they are now. We are going to be using them in a test lab with software installed but the department that is going to be using them is going to be messing with configs and setups to test different things with our customers.  So since they are going to be making all different kinds of changes, I wanted to create a job that will restore the guest OS back to a fresh copy.

There are two ways I was looking at doing this:
1.)Save a copy of all the VHDs to how I want them to be and then create a job each night that would stop the VM and then copy that VHD over the one that the VM is using.  
2.) Create a snapshot and then have a job apply that snapshot each night.

But I am not sure if either of these is the best why to go about this, and two how to actually do it. I've been looking at PS scripts and have only found a way to create and export snapshots, not apply them.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
I'd go with option 2 and use a powershell script to rollback the machines to the previous state.  If you want it to occur automatically, use it in a scheduled task.  

You can download the PowerShell Management Library for Hyper-V from:
http://www.codeplex.com/PSHyperv

The key powershell term you're looking for is Apply-VMSnapshot.

How to Administer Microsoft Hyper-V from the command line (CLI):
http://www.virtualizationadmin.com/articles-tutorials/microsoft-hyper-v-articles/storage-management/administer-microsoft-hyper-v-command-line-cli.html

Example script:
http://blogs.technet.com/tonyso/archive/2009/08/18/hyper-v-how-to-apply-vm-snapshot-with-script.aspx

Good Luck!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial