our company is currently using a product that pushes operating system and software updates to our vms, and takes a snapshot prior to pushing the updates in case something breaks. the catch, is that the same software doesn't delete the snapshots until the next update push, and that is just too long for us to wait with snapshots hanging around. what i have done to remedy that is i have built the script shown below and configured it as a scheduled task;
# Add the powercli snap in
Add-PSSnapin VMware.VimAutomation.Core
# Connect to a vCenter instance
$strviserver = "vCenterServer"
Connect-VIServer $strviserver
# Get all of the named snapshots for each VM in this vcenter and delete them
Get-VM | Get-Snapshot -Name "updates" | Remove-Snapshot -Confirm:$false
# Remove the powercli snap in
Remove-PSSnapin VMware.VimAutomation.Core
This works, but it is not near as efficient as I would like it to be. Essentially, the script currently deletes one snapshot at a time right now. I would like for it to find all of the snapshots on that vcenter server with that specified name, and submit the Remove-Snapshot task for each snapshot simultaneously. This should cause a lot of tasks to be submitted and just queue up. The effective result would be that vCenter will process as many snapshot deletions as it has resources to do in a given time, and will process the queue as it has resources. If anybody can tell me how to accomplish this or something better, I would really appreciate it! Thanks in advance!