Hi,
Is it possible to process all objects in a foreach loop without waiting for the previous object to complete?
So for instance
$Services = Get-Service
Foreach ($Service in $Services)
{
Stop-Service -Name $Service.
}
Is there a way to do all in one hit?
Cheers
You could do it with a workflow
workflow MyStopService
{
$services = get-service
foreach -parallel ($service in $services)
{
stop-service -name $service
}
}
Now this doesn’t do anything about services that stop one service when stopping themselves - but this is at least one way you could accomplish what you were looking to do.
Thanks Paul, the workflow seems to have done the trick.
Cheers