I'm writing a script to remove VMware snapshots and I want to be able to run, say, 4 removals at a time so as to avoid putting too much load on the SAN.
The snapshot removal command - Remove-Snapshot - has a '-RunAsync' option, so I can make it execute on one VM and then immediately move on to the next VM. This is great, but if I feed it my list of 40+ VMs then it's going to immediately kick off 40 snapshot removal operations. I can't figure out how to make it stop after 4 executions and then wait until one finishes before adding the next one.
In other words, I can't figure out a way to make the script do: remove snapshot but keep an eye on it and report back when it's done.
Any ideas?
The snapshot removal command - Remove-Snapshot - has a '-RunAsync' option, so I can make it execute on one VM and then immediately move on to the next VM. This is great, but if I feed it my list of 40+ VMs then it's going to immediately kick off 40 snapshot removal operations. I can't figure out how to make it stop after 4 executions and then wait until one finishes before adding the next one.
In other words, I can't figure out a way to make the script do: remove snapshot but keep an eye on it and report back when it's done.
Any ideas?