Calling other PowerShell scripts within a PowerShell script Calling other PowerShell scripts within a PowerShell script powershell powershell

Calling other PowerShell scripts within a PowerShell script


PowerShell can run PowerShell scripts from other PowerShell scripts directly. The only time you need Start-Process for that is when you want to run the called script with elevated privileges (which isn't necessary here, since your parent script is already running elevated).

This should suffice:

foreach ($script in $scriptList) {    & $script }

The above code will run the scripts sequentially (i.e. start the next script only after the previous one terminated). If you want to run the scripts in parallel, the canonical way is to use background jobs:

$jobs = foreach ($script in $scriptList) {    Start-Job -ScriptBlock { & $using:script }}$jobs | Wait-Job | Receive-Job