I am trying to do something like the following:
Workflow spawnInParallel() {
$task1 = { "Dir C:\; pause" }
$task2 = { "Dir C:\Windows; pause" }
$task3 = { "ng build --prod; pause" }
$tasks = $task1, $task2, $task3
ForEach -Parallel ($task in $tasks) {
start powershell "& $task"
}
}
spawnInParallel
I am encapsulating DOS commands as a string simply because I don't know a cleaner way.
I don't know if this is a task for Workflow, Jobs or something else.. Looking to hopefully keep it clean and simple.. Using PS 5.1.
The desired result would be the original, plus 3 new Powershell Windows that run the command and not immediately close.
Implementation Using Updated Accepted Answer
Workflow showParallel() {
param([String[]] $procs)
$tasks = @()
foreach ($proc in $procs) {
$tasks += " cmd.exe /c 'Echo Running $proc&$proc&pause' "
}
foreach -parallel ($task in $tasks) {
Start-Process powershell "-c $task"
}
}
$app1BuildCmd = "ng build --app app1 --prod --output-path $app1Root"
$app2BuildCmd = "ng build --app app2 --prod --output-path $app2Root"
$app3BuildCmd = "ng build --app app3 --prod --output-path $app3Root"
showParallel -procs @($app1BuildCmd , $app2BuildCmd , $app3BuildCmd )