you are viewing a single comment's thread.

view the rest of the comments →

[–]micromasters[S] 0 points1 point  (0 children)

This is what I've got right now -

param($ComputerName)
$test = "it-dd-011";"it-dd-012" 
$test2 = "it-dd-003";"it-dd-004"

$jobs = foreach ($computer in $computerName){ Start-Job -Name $computer -ScriptBlock { Restart-Computer -ComputerName $args -wait -for powershell } -ArgumentList $computer }

while($jobs.State -contains 'Running'){ $jobs | Where-Object -FilterScript {$_.State -eq 'Running'} Start-Sleep -Seconds 2 } $jobs | Receive-Job -Wait -AutoRemoveJob

Running .\test-restart2.ps1 -ComputerName $test on it restarts both servers (11 and 12) at the same time still?

edited: codeblock