Removing VMware Snapshots – With a Bat (PowerShell, CLI, rCLI… and Perl)

I’ve found a few situations in which snapshots get stuck, like glue, to a running VM, and despite your best effort to delete them, they wont go away. Like in-laws, they stick around, a bit longer than is pleasant.

If a snapshot has not been removed cleanly on the first try, you may want to create a new snapshot first (just to make sure the system knows there IS a snapshot present) before using the methods below.

Here are a few ways of getting rid of the ones that don’t want to go away:

From the Service Console (ESX)

[root@esx esx:storage1]# vmware-cmd ./VMname/VMname.vmx removesnapshots
removesnapshots() = 1

From PowerShell

PS C:\> get-vm VMname* | get-snapshot | Remove-Snapshot -Confirm:$false

Using the rCLI

C:\Program Files\VMware\VMware VI Remote CLI\bin>vmware-cmd.pl -H esx -U root –P  password /vmfs/volumes/esx:storage1/VMname/VMname.vmx removesnapshots
removesnapshot () = 1

Using the Perl Toolkit

This brought to us by Andrew, an avid Perl Toolkit user:
./snapshotmanager.pl –server your.vc.host –operation removeall –vmname some.bad.vm

Warning, depending on the size of the snapshot, it may take a LONG while for them to go away! You can get an idea of how long it’s going to take by looking at how large the snapshots are with ls -lh and note the size of your largest snapshots. They bigger than a few deciGig (for those who don’t get it, that’s a few tens of Gigs, 10G-20G)? Shame on you.

23 thoughts on “Removing VMware Snapshots – With a Bat (PowerShell, CLI, rCLI… and Perl)

Comments are closed.