Continuing with the theme of using an easy array (1..20) with a forEach to do a code block a defined number of times, I cobbled this together yesterday. I can't figure out how to get the output on a single line yet, but it works; will ping entire subnet and report which ones respond.
(1..255) | % {
"192.168.0.$($_)"; Test-Connection "192.168.0.$($_)" -quiet -count 1 | % {
IF($_ -eq $True){"IP above pings"}
}
}
The % is an alias for ForEach
Friday, June 18, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment