
We can use Test-Connection cmdlet here, it sends ICMP echo request packets (“pings”) to the list of IP address you define. Then we just need to loop through the entire range using first three IP octet as prefix and writing desired output.
1 2 3 4 5 6 7 8 | 1..254 | ForEach-Object { if(!(Test-Connection 10.219.111.$_ -count 1 -Quiet)) { Write-Output "10.219.111.$_ is available" } else { Write-Output "10.219.111.$_ is in use" } } |
Leave a Reply