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.
Start there, then drill down to the individual VMs. The entries that have values in Bytes (B) essentially mean that there are no snapshots.
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 = "vsphere.ad.example.com"
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
Gives:
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.
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.
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. :-)
Unfortunately the thick client for Vcenter hasn't had this feature ever since 6.0 I believe but here's another option if you want to do it easily in a GUI. In 6.0 or 6.5 launch the vcenter web client (flash version). On the left side (navigator window) select either vcenter, a data center, or a cluster then select to view VMs. On the right hand side to the left of the "filter" box there's a small square icon (hovering over it says "Show and hide quick filters". click that square icon, then click "has snapshot" then click "yes". Your view will now display only VMs with snapshots. Enjoy!
Or run the following query in MS SQL (query is based on sql2008 and vcenter 5.1)
select t.ID, t.NAME as VMName, s.SNAPSHOT_NAME as SnapshotName
from [VCDB].[dbo].[VPX_SNAPSHOT] s, [VCDB].[dbo].[VPX_ENTITY] t
where s.VM_ID = t.ID order by t.ID
Simple native method to do that is just use the following one liner on the targeted ESXi host after you SSH to it and it will show you the VM id and it's snapshot detail beneath:
SSH to the ESXi and run this:
for i in $(seq 1 60); do echo 'VM Id:' $i && vim-cmd vmsvc/get.snapshotinfo $i; done
Once you get the result VM id from the above command, run the below command to get all the VM IDs and details to get the exact name of the VM.
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.
Start there, then drill down to the individual VMs. The entries that have values in Bytes (B) essentially mean that there are no snapshots.
Sounds like a job for PowerCLI! Well, from a Windows workstation, anyway, which is what I have.
Get-Snapshot
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.
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 = "vsphere.ad.example.com"
Gives:
You can then pipe that into
Remove-Snapshot
or filter it or whatever.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.
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. :-)
This worked for me in vSphere 6.7 (Web Client):
Unfortunately the thick client for Vcenter hasn't had this feature ever since 6.0 I believe but here's another option if you want to do it easily in a GUI. In 6.0 or 6.5 launch the vcenter web client (flash version). On the left side (navigator window) select either vcenter, a data center, or a cluster then select to view VMs. On the right hand side to the left of the "filter" box there's a small square icon (hovering over it says "Show and hide quick filters". click that square icon, then click "has snapshot" then click "yes". Your view will now display only VMs with snapshots. Enjoy!
Or run the following query in MS SQL (query is based on sql2008 and vcenter 5.1)
Open vCenter with vSphere Client. Navigate to
"Datastore and Datastore Cluster" Category
"R-Click on Datastore" where you want to find Snapshot. (If multiple Datastore then have to go in each Datastore)
You will See Folder and Search Tab.
Click to See Image of Search Tab
Click on Search, Then from Drop Down select "Virtual Machine Snapshot"
Click Search.
It will show all the Snapshot stored in that datastore.
R-Click on Snapshot and "Go to Folder"
It will take to VM Folder of which Snapshot is taken.
Simple native method to do that is just use the following one liner on the targeted ESXi host after you SSH to it and it will show you the VM id and it's snapshot detail beneath:
SSH to the ESXi and run this:
Once you get the result VM id from the above command, run the below command to get all the VM IDs and details to get the exact name of the VM.
Good luck!