I am trying to delete old snapshots after patching using PowerCLI. The code i am using now is:
Get-VM | Get-Snapshot | Remove-Snapshot -confirm$false
It works great...but it only removes one at a time, and i would like it to do 2-3 at a time. Is this possible?
Thanks in advance!
This code will remove multiple snapshots from all virtual machines:
Get-VM | Get-Snapshot | % { Remove-Snapshot $_ -Confirm:$false }
I would recommend selecting a single virtual machine and testing first:
$VM = Get-VM -Name 'My Virtual Machine'
$VM | Get-Snapshot | % { Remove-Snapshot $_ -Confirm:$false }
Tested to work on PowerCLI 6.5.
I would recommend taking a look at the 'RunAsync' parameter. This will create the task and then move onto the next task without waiting for the prior task to complete.
Example:
Get-VM | Get-Snapshot | Remove-Snapshot -RunAsync -Confirm:$false
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.