Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4
don - in your Month of Lunches book chapter 9.8 you have ideas for on your own and ask:
Or use Test-Connection to ping several
computers, and only show the results from computers that did not respond
I tried several things then did what I do best and stole a cmd and came up with this (I am sure you know where I stole it from…J)
get-content c:\hold\machines.txt | foreach { if (test-connection $_ -quiet) { $null } else {write-host "$_ is down" -foregroundcolor RED}}
Now I get the desired results but my question is : how does it know if it’s up or down? All I did was run a test-connection and then a write-host. I didn’t call for anything like statuscode or timeout and say if statuscode is X then …….
Also if I ping a computer (who is in dns but not up) I get request timed out…..but test-connection gives me:
Test-Connection : Testing connection to computer 'XXXX' failed: The requested name is valid, but no data of the requested type was found At line:1 char:16 + test-connection <<<< XXXX + CategoryInfo : ResourceUnavailable: (XXXX:String) [Test-Connection], PingException + FullyQualifiedErrorId : TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand