how to check which vms have snapshots in a very dirty but quick way?

by Grzegorz Kulikowski

I have written more advanced scripts for printing, reporting stuff about snapshots than this one, but here it is just about to see which vm has snapshot. That is all i want by running this command. And i want to see the results FAST!, i mean NOW!, or like YESTERDAY! 😉
[sourcecode language=”powershell”]
Get-View -ViewType VirtualMachine -Filter @{"snapshot" = ""} | select name
[/sourcecode]
bam!
That’s it ;], nothing more. It will just output the vSphere .net view object for vms that have snapshots on it. Once again, it is not fancy, it does not send e-mail, it does not do coffee while running, it just shows you vms with snapshots on it. You can build your own “EXTRA” around this if you want. I just wanted to see very quickly if i have snaps or not. If you have any better idea / quicker how to view snapshots on vm, please post a comment!

You may also like

2 comments

Bob October 25, 2016 - 10:32 pm

Hi there!
This is a really old post but I just wanted to respond to your question if there is a better/quicker way to get the list. There is.
By only retrieving the properties you case (in this case Name) you can cut the execution time significantly.

Check it out:
Measure-Command {
Get-View -ViewType VirtualMachine -Filter @{“snapshot” = “”} | Select Name
}
# 960 milliseconds on a system with 500 VM and 116 snapshots.

Measure-Command {
Get-View -ViewType VirtualMachine -Filter @{“snapshot” = “”} -Property Name | Select name
}
# 96 milliseconds on the same system (e.g. 1/10 of the execution time). That is an improvement…

Reply
psvmware October 26, 2016 - 9:51 am

Hi Bob, yep, of course that will be faster 😉 This is quite an old post. I already wrote a post with how to use get-view with -property. Still, thanks for noticing!

Reply

Leave a Reply

Chinese (Simplified)EnglishFrenchGermanHindiPolishSpanish
Streaming live on Twitch right now.
CURRENTLY OFFLINE