Command Prompt: for /L %i in (1,1,254) do @ping -n 1 4.2.2.%i | find "Reply" Powershell: 1..254 | % { $ip = "4.2.2.$_"; if (Test-Connection -ComputerName $ip -Count 1 -Quiet) { $ip } }