Skip to content

Instantly share code, notes, and snippets.

@jimfdavies
Created February 21, 2013 09:57
Show Gist options
  • Save jimfdavies/5003602 to your computer and use it in GitHub Desktop.
Save jimfdavies/5003602 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment