Hi,
Just wondering if there's a way to track the progress (% completed) of each task in the pipeline for a bunch of objects, and also run concurrent command in the pipeline. Don't think write-progress can be used for this purpose.
I have a script that serially migrate a list of VMs every night to a different datastore (storage vMotion). Each VM is quite huge (provisioned size around 1TB) and takes about 3 hours to migrate each. What I want for each VM in the pipeline that is being migrated, is to track how much of the migration is completed (for each VM, not for the VMs in the array as a whole) so I can send out an email notification of the progress for each VM every hour that has passed.
1. Pass each vm in the array to foreach and execute move-vm in concurrence with a bunch of other commands (in pseudo code below)
2. WHen the stopwatch instance hits 1 hour (meaning the storage vmotion for the vm in the pipeline has been going on for an hour), call an email notification function passing the %completed of the current VM being migrated
$vmarray | foreach { #need all command here to run concurrently
move-vm $_ -datastore (get-targetdatastore)
$ElapsedTime = [System.Diagnostics.Stopwatch]::StartNew()
$percentcompleted = get-progress (imaginary function) #this is what I what I need help with
$triggerdue = $elapsedtime.minutes -eq 60
While ($true) {
if ($triggerdue) {$elapsedtime.reset; send-notifmail
$percentcompleted}
}
}
Looking at [runspacefactory]::CreateRunspacePool to run these commands in concurrence but is there a "PS native / more powershell-ish" way to do this?
Thank you very much.