Morning folks,
I'm working on a Do/Until
loop that tracks an invoke-command
job against multiple servers. What I don't know how to capture in the Until
block is to continue doing the loop until all servers report a Completed
status.
below is my test code
Invoke-Command -ComputerName Server01,Server02,Server03 -ScriptBlock{sleep -s 120} -AsJob -JobName "Test Job"
Do{
Write-Host "Job is still running"
sleep -s 10
}Until((Get-Job "Test Job").state -eq "Completed"
I'm thinking I need to put the following in the Until block but I'm not sure
Until(ForEach($job in (Get-Job "Test Job")){
$Job.State -eq "Completed"
})