Based on How to execute a PowerShell function several times in parallel?, I'm able to do this, where I stop all running jobs, in parallel.
# Run this in parallel
$stopService {
param($service)
Stop-Service -Name $service.name -Force
}
$services = Get-Services | Where-Oject {$_.name -like "*XYX_*"}
Foreach($service in Sservices) {
Start-Job -ScriptBlock $stopService -ArgumentList $service
}
$doSomethingElse
But how can I modify the code so all my parallel jobs finish first before I $doSomethingElse
?. Kinda like a join()
command?