Quickly Ping A Range of IP to Find Dead IP on Windows

PowerShell

Instead of looking for a tool, there is a very quick and easy way that lets me ping a wild range of IPs to find out which IPs are free and which ones have been taken, using the PowerShell built-in cmdlet Test-Connection.

And here is how:

$iprange = 200..254
Foreach ($ip in $iprange)
{
    $computer = "192.168.37.$ip"
    $status = Test-Connection $computer -count 1 -Quiet
    if (!$status)
    {
        $computer + " - available" 
    }
}
image 15 - Quickly Ping A Range of IP to Find Dead IP on Windows

Copy the code over to PowerShell ISE console, change the IP info and hit the green Go button. You will get the result within a minute.

I personally really like this block of code because I can run many other things between each IP loop to gather more information about each computer on the network, such as uptime, hard drive usage, etc. But if you prefer a one-liner that gives you a set of simple result, try this.

200..254 | foreach { $status=Test-Connection "192.168.37.$_" -Count 1 -Quiet; "192.168.37.$_ $status"}

Hope it helps.

Leave a Reply

Your email address will not be published. Required fields are marked *