Wednesday, March 12, 2014

PowerCLI: Remove Largest Snapshots First

Here is a nice powershell one-liner to remove the largest snapshots first.  This removes one snapshot at a time.


get-vm | get-snapshot | sort-object sizemb -descending | Remove-Snapshot -confirm:$false

If you want to do it for VMs of only a certain size, where snaps are larger than 1GB:


get-vm | get-snapshot | where {$_.SizeMB -gt 1024} | sort-object sizemb -descending | Remove-Snapshot -confirm:$false

Enjoy!


No comments:

Post a Comment

Featured Post

Remove 3D Objects and other annoying folders on Windows 10

 Microsoft just keeps adding more crap to clutter up the navigation in Windows 10.  Seriously, who needs a 3D Objects folder?  The tiny perc...