Getting a list of all the snapshots in VMs managed by vCenter?

Solution 1:

Grrr... VMware snapshots. If I had my way, they'd only exist for backup purposes and for testing changes.

You can view the space consumed by snapshots (which is probably what you're really interested in knowing) by using the "Storage Views" tab at the cluster level in your vSphere client.

enter image description here

Start there, then drill down to the individual VMs. The entries that have values in Bytes (B) essentially mean that there are no snapshots.

Solution 2:

Sounds like a job for PowerCLI! Well, from a Windows workstation, anyway, which is what I have.


The Surly Admin's blog even has a script that you can copy-pasta to get all the snapshots for all the VMs in your environment, the meat of which I'll post below for your convenience.

$Report = Get-VM | Get-Snapshot | Select VM,Name,Description,@{Label="Size";Expression={"{0:N2} GB" -f ($_.SizeGB)}},Created
If (-not $Report)
{  $Report = New-Object PSObject -Property @{
      VM = "No snapshots found on any VM's controlled by $VIServer"
      Name = ""
      Description = ""
      Size = ""
      Created = ""
$Report = $Report | Select VM,Name,Description,Size,Created | ConvertTo-Html -Head $Header -PreContent "<p><h2>Snapshot Report - $VIServer</h2></p><br>" | Set-AlternatingRows -CSSEvenClass even -CSSOddClass odd

Solution 3:

HopelessNoob's answer is great for a human readable report. Sometimes I prefer to parse mine into other PS objects. It is very similar too HopelessNoob's - I guess we both started from the same code snippet to build our scripts:

$VIServer = ""

If (-not (Get-PSSnapin VMware.VimAutomation.Core))
{  Try { Add-PSSnapin VMware.VimAutomation.Core -ErrorAction Stop }
   Catch { Write-Host "Unable to load PowerCLI, is it installed?" -ForegroundColor Red; Break }

Connect-VIServer $VIServer -Credential (Get-Credential) | Out-Null

Get-VM | Get-Snapshot | Select VM,Name,Description,@{Label="Size";Expression={"{0:N2} GB" -f ($_.SizeGB)}},Created | FT


VM                              Name                            Description                     Size                            Created
--                              ----                            -----------                     ----                            -------
ENETSXS2                        VEEAM BACKUP TEMPORARY SNAPSHOT Please do not delete this sn... 19.28 GB                        8/11/2014 8:42:18 AM
ENETSDFS-BS                     VEEAM BACKUP TEMPORARY SNAPSHOT Please do not delete this sn... 16.30 GB                        8/11/2014 5:24:44 AM

You can then pipe that into Remove-Snapshot or filter it or whatever.

Solution 4:

Here is the script that we use to dump a list of all of the VM's with snapshots, works in PowerCLI. It is very simple and clean. It will dump the results to your local desktop via a .csv file.

#  Possible "Select-Object -Property" variables: Description, Created, Quiesced, PowerState, VM, VMId, Parent, ParentSnapshotId, ParentSnapshot, Children, SizeMB, SizeGB, IsCurrent, IsReplaySupported, ExtensionData, Id, Name, Uid, Client

get-vm | get-snapshot | Select-Object -Property vm,created,sizeGB,name,description | Export-Csv -Path C:\Users\$env:username\Desktop\snapshots.csv

Solution 5:

Even if an answer has been accepted, I'd like to point you to check_vmware_snapshots.
It's a Nagios / Icinga plugin, to check the age and count for VM snapshots in a VMWare ESXi/vSphere environment.

It depends on Perl / VMware::VIRuntime from "VMware-vSphere-CLI-5.5.0", so no PowerCLI or -shell this time. :-)