Search code examples
powershellprocesswait

Waiting in PowerShell for all child processes to finish


I want to execute multiple external scripts in PowerShell simultaneously and then wait for all of them to finish before proceeding. Currently I am using 'start-process -NoNewWindow ...' commandlet that loops through all child processes but then terminates.

I have found many ways to wait for 1 process to finish (this is obviously trivial) but none of them seem to work as a solution for my problem.

Having an equivalent for UNIX version in PowerShell would definitely be what I am looking for.


Solution

  • And don't forget about probably the most straight forward way to do this for mulitple processes - Wait-Process e.g.:

    $procs = $(Start-Process Notepad.exe -PassThru; Start-Process Calc.exe -PassThru)
    $procs | Wait-Process