chris1984
3/27/2018 - 8:34 PM

Quick script to ping a subnet and report if each IP address is used or 'empty'. Can be extended to redirect to a file if desired.

Quick script to ping a subnet and report if each IP address is used or 'empty'. Can be extended to redirect to a file if desired.

$subnet24 = "10.10.1"

1..254 | 
foreach-object { 
    $ip = $subnet24 + "." + $_
    if (test-connection $ip -count 1 -quiet) { Write-Host "USED:$ip" } else { Write-Host "EMPT:$ip" } 
}

#USED:10.10.2.1
#EMPT:10.10.2.2
#...
#USED:10.10.2.254