Monthly Archives: April 2012

NSLookup Sweep

I keep finding the need to find an open IP address for a new server, and I get tired of searching manually.  I am also not patient enough for a ping sweep, so I created a nslookup sweep with powershell. The nslookup sweep just looks through a subnet to find the first address without a dns entry. The next step just requires you to ping the address to insure it’s not being used.  Check out this post for a TCP Port Scanner in PowerShell.


$i = "1";
$subnet = "192.168.1";
while ( $i -lt 255 ) {
$ipaddr = "$subnet.$i"
$nsResult = nslookup $ipaddr 2>&1 | select-string "Name";
if ( $nsResult ) {
$i++;
}else{
echo "$ipaddr is available";
$i = "256";
}
}