Hi,
I'm writing a script which will include one or more reboots of remote servers.
For this I'm using a parallel workflow and the Restart-Computer cmdlet with the -Wait (and also -Force) parameter. I have the console session to the server open, so I follow the reboot procedure, which works. The job just never resumes when the server comes
back up. Instead it hangs on this step:
"Waiting for Windows PowerShell connectivity..."
If I cancel out, I can immediately run it again without issue, and it will proceed to reboot the servers and then hang at the same step again. Since these are workgroup servers right now, I also pass pscredentials.
Have you seen this behavior before? Any idea what I am missing?
I based the workflow on the simple example given by the Scripting Guys blog.
$ComputerNames = 'IP1','IP2','IP3','IP4'
$Credential = (Get-Credential)
workflow Test-Restart {
param (
[string[]]$ComputerNames,
[pscredential]$Credential
)
foreach -parallel ($Computer in $ComputerNames) {
Get-WmiObject -Class Win32_ComputerSystem -PSComputerName $Computer -PSCredential $Credential
Restart-Computer -Wait -Force -PSComputerName $Computer -PSCredential $Credential
Get-WmiObject -Class Win32_ComputerSystem -PSComputerName $Computer -PSCredential $Credential
}
}
Test-Restart -ComputerNames $ComputerNames -Credential $Credential
Andreas Hultgren<br/> MCTS, MCITP<br/> <a href="http://ahultgren.blogspot.com/">http://ahultgren.blogspot.com/</a>