Build and Restore Snapshots in Hyper-V with Windows PowerShell

Summary: Microsoft PowerShell MVP, Sean Kearney, talks about using Windows PowerShell to build and restore snapshots in Hyper-V.

Microsoft Scripting Guy, Ed Wilson, is here. If you are a seasoned Hey, Scripting Guy! Blog reader, you know that the most frequent guest blogger is Sean Kearney. If you are new to the blog, I welcome you, and I encourage you to catch up with Sean’s previous blogs.

Sean is a Windows PowerShell MVP and an Honorary Scripting Guy. Sean has been selected to present sessions called Integrating with Microsoft System Center 2012 and Windows PowerShell at TechEd NA and TechEd Europe this year. In his free time, Sean has written several blog posts about Hyper-V and some other cool stuff, and for the next few weeks, Sean will be the designated guest blogger on Fridays. Take it away Sean…

With Microsoft TechEd Europe and a few other presentations on the horizon, I was thinking about how nice it would be have my environments self manage for the demos.

Typically with most demos in a virtual environment, you make a snapshot of everything in the Gold setup. Then when you enter into your presentations, you can immediately roll back to the original configuration to prepare for your next presentation.

Or perhaps you’re firing up a test environment, and you need to be able to take a snapshot and restore sets of machines to troubleshoot a package issue.

With Windows Server 2012 and the new Hyper-V module, this is as natural as breathing.

Let’s say we have a list of virtual machines in our environment: a domain controller, a SQL Server, and perhaps our web application. We’ll name them DC1, SQL1, WEB1. Although these are the NetBios names, for convenience I have given them the same names in Hyper-V.


To create a checkpoint on the virtual machines, we can simply use the Checkpoint-VM cmdlet and run it like this:

CHECKPOINT-VM –Name DC1 –Snapshotname ‘Base’

This will not only create a snapshot, but it will have a unique name that we can refer to. To run this against a list of machines, we can pipe the list by using Get-VM or supply a list like in our variable:

$VMNames | GET-VM | CHECKPOINT-VM –SnapshotName ‘Base’

This will create a snapshot named “Base” on the virtual machines named DC1, SQL1, and WEB1.

If we’d like to access all of these snapshots, we can run this command:

$VMNames | GET-VM | GET-VMSnapshot –Name ‘Base’

We can now take this list and restore them:

$VMNames | GET-VM | GET-VMSnapshot –Name ‘Base’ | RESTORE-VMSnapshot –confirm:$False

One line and now I can restore any demo by using Windows Powershell. With very minor changes, I can create multiple snapshots with unique names by changing the name of snapshot.

Cool, eh?

Feel the Power within you.

The Energized Tech

Great job, Sean. Join us tomorrow for more cool Windows PowerShell stuff.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy

Comments (7)

Cancel reply

  1. Anonymous says:

    waste my time for long hours…finally found this High Quality are the best.

  2. jrv says:

    @Sean – thanks!


    I spent an hour trying to guess how to make a snapshot.  "Checkpoint"!  Love those guys and their amazing flying machine.  Checkpoint?  Who would have thought?

    Ratzafratz – another hour of my life lost because of those creative guys at Microsoft.

    Ok – 'Checkpoint' is probably the best name but "who woulda, coulda, shoulda….????"

    Another great bit from Sean. Thank you Ed/Sean.

  3. Hammer says:

    @JRV One would have thought -Snapshot would have worked just as well, but that would just be too easy wouldn't it? 🙂

    I'm loving these Hyper-V related articles, keep it up please.

  4. Krunch {The Commenter formerly known as K} says:

    @jrv its the same naming convention as Checkpoint-computer cmdlet, blame the PoSh v2

  5. fred says:

    Doesn't work on Windows Service 2008 R2

  6. Logan says:

    is there a way like this to create/restore checkpoint in Windows 2008 R2 Hyper-V environment? This is cool blog article but without Microsoft's new Hyper-V cmdlet such as Get-VM, Checkpoint-VM, what we should do in older version of Hyper-V and PS? Thanks.


  7. I have 14 VMs but I need to take snapshot of just 8 VMs, what will be the script for it?

Skip to main content