PowerCLI: Delete all snapshots by name

I have the issue that we use a cloud automation software, which for whatever reason failed to delete the hypervisor snapshots.

Now I was looking into a quick way to delete all those 520 snapshots with PowerCLI, and I found something pretty quick.

 

Based on that, I came up with my own quick PowerCLI one-liner, that’ll list all VMs and their snapshots:

Now, I could use another one-liner to delete all snapshots, that’ll look like this:

However, this will either crash an ESXi host (because the amount of the snapshots is too much) or overwealm the storage. So in the end I used a script like this:

This’ll limit the maximum amount of snapshots to delete at times to 5 (or 10 if you change the $maxtasks value).

Leave a Reply

Your email address will not be published. Required fields are marked *

I accept that my given data and my IP address is sent to a server in the USA only for the purpose of spam prevention through the Akismet program.More information on Akismet and GDPR.

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