Home > Hyper-V, Powershell, Virtualization > Virtual Machine Snapshots in Win8 Hyper-V massage with PowerShell

Virtual Machine Snapshots in Win8 Hyper-V massage with PowerShell

In the new win8 there is a function to merge the snapshot taken on a VM without putting it into saved state/turn off. In the Windows 2008 and 2008 R2 there was a big no-no to taking snapshots on production machines, how about now in the new version? Well their replication function uses snapshots so it must be good enough. Then as always you should consider the consequences of taking snapshots and rolling back on different systems as the data in a database may be lost when jumping around.

The Cmdlets that are relevant for Snapshots :

  • Checkpoint-VM
  • Get-VMSnapshot
  • Remove-VMSnapshot
  • Export-VMSnapshot
  • Restore-VMSnapshot
  • Rename-VMSnapshot

If you search among the cmdlets the first CheckPoint-VM is not very easy to find, I am woundering why they(MS) has decided that name?! (I have before complained about checkpoint in SCVMM, maybe it is from there it has the roots)

Here is a PowerShell oneliner that makes 50 Snapshots on a VM (the limit of 50 snapshots is still valid as i tested to make 60 snapshots and got errors from 50+)

for($i=1 ;$i -le 50 ; $i++){Checkpoint-vm -SnapshotName $i -VMName lajs}

Here is the error.

How do I know how many snapshots i have on a VM?

Or if you must, check the GUI..

When I now have 50 snapshots I have to remove one before taking a new, the Remove-VMSnapshot has a parameter -IncludeAllChildSnapshots that is quite handy if you have like me 50 snapshots that you want to remove. I use the Select-Object -First 1 to get the first snapshot so i can remove all at once.

Get-VM lajs | Get-VMSnapshot | Select-Object -First 1 | Remove-VMSnapshot -IncludeAllChildSnapshots

How about the cmdlet Export-VMSnapshot, it cannot be run when the VM is running, but it creates an exported VM that is from the snapshot. This can be very useful if you want to have a machine from a specific snapshot built.

How to go to a snapshot with Restore-VMSnapshot then, when I restore I have to confirm but not when deleting?

If you haven´t found the reference page on technet for WIN 8 Hyper-V powershell cmdlets it is here.

Categories: Hyper-V, Powershell, Virtualization Tags:
  1. No comments yet.
  1. No trackbacks yet.