Hi
Found a nice little introduction to workflows and the foreach -parallel construct. I thought that would come in very handy for a script that pings a lot of servers to see if any are down. So I clobbered it together, fed it a list of 700 servers and sat back please with myself that it would finish in a fraction of the time.
Didn't work. Ran for quite a few of them (and clearly in parallel judging by the way the output came back), but then:
The operation did not complete within the allotted timeout of 00:00:30. The time allotted to this operation may have been a portion of a longer timeout. At Parallel-Ping:15 char:15++ CategoryInfo : InvalidResult: (:) [], TimeoutException+ FullyQualifiedErrorId : JobStateFailed
Here's the code I used, any way to change the length of timeout? Google not really helping me here. Or perhaps some better way to accomplish this? A fast parallel-ping of such a large list of objects?
workflow Parallel-Ping { param( [string[]]$Computers, [boolean]$DownOnly ) foreach -parallel ($computer in $computers) { if (!(Test-Connection -ComputerName $computer -Count 1 -ErrorAction SilentlyContinue)) { "$Computer is DOWN" } else { if (!($DownOnly)) { "$Computer is UP"} } } } $Computers = Get-Content servers.txt Parallel-Ping $Computers
Thanks !
A