1..255 | foreach-object {
[System.Net.Networkinformation.Ping]::new().Send("192.168.1.$_") } |
where-object {$_.Status -eq "success"} | select Address
Output:
Address ________ 192.168.1.1 192.168.1.20 ...
Instead of 1..255 you can also use something like:
(1..3),5,(7..10) => 1, 2, 3, 5, 7, 8, 9, 10