PowerShell one liners for Hyper-V demo and training environments

Today I’m attending the ITCampNL in Eindhoven where two Microsoft employees are giving a workshop on Hyper-V in Windows Server 2012.
One of the things they asked me on the spot were a few management tasks through PowerShell such as restoring all virtual machines to a snapshot that has previously been taken.

Than I came to think about it and I would like a few PowerShell one liners to do everything with snapshots that is required for a demo and/or training environment such as creating snapshots, reverting to them and even deleting them.
So… here we go.

To create snapshots on all virtual machines:

And to revert all virtual machines to those snapshots:

Next is of course to remove the snapshots:

And finally to remove the snapshots and all child snapshots:

I hope that you find these as useful as I’m hoping you will 😉

Leave a Reply

Your email address will not be published. Required fields are marked *