Is there a fast function for pinging a list of machines using PowerShell?
I know I can use Test-Connection:
Test-Connection -Count 1 -ComputerName (gc .\comps.txt) -ea silentlycontinue
but this seems painfully slow (I'm assuming because it uses Win32_PingStatus).
Even better would be an example of how running it as a background job to speed it up would be most useful.
Unlike the familiar ping command, Test-Connection returns a TestConnectionCommand+PingStatus object that you can investigate in PowerShell. The Quiet parameter returns a Boolean value in a System. Boolean object for each tested connection. If multiple connections are tested, an array of Boolean values is returned.
You can't stop a continuous ping without signaling the ping process to stop. You would need to use ping /n COUNT for a number of pings.
So, how do you ping in PowerShell? Use the 'Test-Connection' applet. It's that easy. Much like you would use 'ping' in CMD, type in 'Test-Connection' followed by '-Ping', '-TargetName', and an IP address to send a ping to that device.
The PowerShell Community Extensions include a fast ping (among other useful scripts and aliases)
http://pscx.codeplex.com/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With