Monday, July 28, 2014

Scripting Hyper-V on Windows 8

I am working up a SharePoint farm in Hyper-V on my nifty new (and large) laptop and there are a few scripts that I use rather often.  I don't have any other VMs on my box, so they are non-discriminatory, but some simple naming conventions would allow extending them to respect labs.  Here they are:

PS D:\Lab Scripts> Get-VM | Stop-VM

PS D:\Lab Scripts> Get-VM | Checkpoint-VM -SnapshotName "Base"

PS D:\Lab Scripts> Get-VM | GET-VMSnapshot –Name "Base" | 
                            RESTORE-VMSnapshot –confirm:$False

PS D:\Lab Scripts> Get-VM | Start-VM

For a little more information about what is going on, Get-VM gets a list of the VMs on the machine and the pipe ( | ) passes the list as arguments to the next command.  I will leave the rest of the commands for you to look up, assuming they aren't perfectly obvious.

No comments:

Post a Comment