The following script will search all VMs for snapshots, total them (even if there are multiple snapshots per VM) and present the results. If the script returns nothing to screen, then no snapshots were found on any VM.
Ensure you install PowerCLI and run the script from there. You can also omit the -user and -password switches if you use SSO and your logged in account has access to vCenter.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# Connect to vCenter connect-viserver -server vcenter01 -user admin -password pass; # Get all virtual machines $vms = get-vm; # Loop through each virtual machine found foreach ($vm in $vms) { $snapshots = $null; # Get all snapshots for this VM (in MB) and add them $snapshots = ($vm | get-snapshot | measure-object sizemb -sum); # Output only if snapshots exist for this VM if ($snapshots -ne $null) { # Convert to GB and round to one decimal place $snapsizeGB = [math]::Round(($snapshots.sum)/1024,1); # Output to screen write-host $vm.name "-" $snapsizeGB GB; } } |