Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

how to alter this code so test-connection will work in parallel

$
0
0

hi

I got this efficient code from Blindrood in a prev post (tnx)

1..255 | foreach { if(Test-Connection "192.168.1.$_" -count 1 -quiet) {"192.168.1.$_  ok"} else{"192.168.1.$_ not ok"} }

This does pings them one by one, which will allow me more actions depending on reply but it is SLOW.

Can someone assist me in altering this to run the pings "in parallel" - probably using -asjob which completely confuses me?

an alternative of running a single test-connection against 255 targets will not allow me (i think ?) to take indevidual action depending on result.

much obliged


roys99


Viewing all articles
Browse latest Browse all 2562


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>