So I was curious as to how many active ip addresses I had on my network and didn’t feel like manually typing “ping <ipaddress>” and wait for it to timeout and then “rinse and repeat”. Along comes Test-Connection and the –quiet and –count switches that allow me to make one attempt and then return a True/False status on whether the ip is active or not.
I then decided that this would make a great one liner that would list out the IP address I am testing followed by the True/False status.
As you can see, it’s a pretty simple one liner that can quickly show you what is active.
1..20 | % {"192.168.1.$($_): $(Test-Connection -count 1 -comp 192.168.1.$($_) -quiet)"}
This worked wonderfully!! Thanks!!
Could you point me to where I can learn a bit more about the syntax you used in that command. It looks like it could be real handy to understand that well. Thanks!
Pingback: For Loops for Fun and Profit | Pivots n Divots