Delete VMware VM Snapshots using PowerCLI

Removing the old snapshots of the Virtual Machine is one of the easiest ways that a virtualization administrator can reclaim storage capacity in their environment.

Unlike reclaiming other resources like CPU or Memory, deleting old snapshots doesn’t require downtime. Now, many of us are guilty of having snapshots that are months old, and sometimes for reasons, we can’t even remember. But unless you have a tool like vRealize Operations Manager, finding and deleting old snapshots can be a lengthy manual process.

There are multiple ways to find the old/stale VM snapshots, you can leverage some smart tools like RVTools to get the snapshots and creation date

or you can write a small PowerCLI script to quickly check and delete the snapshots of the Virtual Machine in the vSphere environment

Get-VM will list all the VMs, you can use regex filter in the Name option

Get-VM -Name asvignesh-*

You can get the snapshots of the VMs using

Get-VM | Get-Snapshot

To get and delete all the snapshots you can use

Get-VM -Name asvignesh-* | get-snapshot | remove-Snapshot 

Also published on Medium.

This site uses Akismet to reduce spam. Learn how your comment data is processed.