I want a windows command line script that will ping a range of ips in a specified subnet, does anyone know if one?

I want a windows command line script that will ping a range of ips in a specified subnet, does anyone know if one?

Thank you,
dsterlingAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Harper McDonaldCommented:
In PowerShell:

For ($i=1;172..254;$i++) {

ping.exe -n 1 ("172.18.4." + $i) | where{$_ -match "bytes=32"}

}

Open in new window


Results:

PS C:\> .\ping.ps1
Reply from 172.18.4.25: bytes=32 time=6ms TTL=64
Reply from 172.18.4.35: bytes=32 time=2ms TTL=64
Reply from 172.18.4.36: bytes=32 time=1ms TTL=64
Reply from 172.18.4.43: bytes=32 time<1ms TTL=128
0
dsterlingAuthor Commented:
So the 254 would be a /24 subnet and for a /25 it would be 128, but what about the second half of the subnet for the /25?

Thank you,
0
Harper McDonaldCommented:
So it will ping 1-254 in the last octet of that one subnet

PS C:\> .\ping.ps1
Reply from 172.18.4.25: bytes=32 time=2ms TTL=64
Reply from 172.18.4.35: bytes=32 time<1ms TTL=64
Reply from 172.18.4.36: bytes=32 time<1ms TTL=64
Reply from 172.18.4.43: bytes=32 time=1ms TTL=128
Reply from 172.18.4.52: bytes=32 time=1ms TTL=255
Reply from 172.18.4.74: bytes=32 time=1ms TTL=128
Reply from 172.18.4.77: bytes=32 time<1ms TTL=128
Reply from 172.18.4.103: bytes=32 time=2ms TTL=128
Reply from 172.18.4.105: bytes=32 time=1ms TTL=128
Reply from 172.18.4.106: bytes=32 time=1ms TTL=128
Reply from 172.18.4.107: bytes=32 time<1ms TTL=128
Reply from 172.18.4.110: bytes=32 time=1ms TTL=128
Reply from 172.18.4.112: bytes=32 time=5ms TTL=128
Reply from 172.18.4.117: bytes=32 time=1ms TTL=128
Reply from 172.18.4.118: bytes=32 time=1ms TTL=128
Reply from 172.18.4.120: bytes=32 time<1ms TTL=64
Reply from 172.18.4.122: bytes=32 time=1ms TTL=128
Reply from 172.18.4.123: bytes=32 time<1ms TTL=128
Reply from 172.18.4.129: bytes=32 time=2ms TTL=128
Reply from 172.18.4.135: bytes=32 time<1ms TTL=128
Reply from 172.18.4.141: bytes=32 time<1ms TTL=128
Reply from 172.18.4.142: bytes=32 time=1ms TTL=128
Reply from 172.18.4.144: bytes=32 time=1ms TTL=128
Reply from 172.18.4.149: bytes=32 time<1ms TTL=128
Reply from 172.18.4.150: bytes=32 time=1ms TTL=128
Reply from 172.18.4.151: bytes=32 time=1ms TTL=128
Reply from 172.18.4.152: bytes=32 time=1ms TTL=128
Reply from 172.18.4.155: bytes=32 time=1ms TTL=128
Reply from 172.18.4.156: bytes=32 time=1ms TTL=128
Reply from 172.18.4.157: bytes=32 time=1ms TTL=128
Reply from 172.18.4.161: bytes=32 time<1ms TTL=128
Reply from 172.18.4.162: bytes=32 time=1ms TTL=128
Reply from 172.18.4.163: bytes=32 time<1ms TTL=128
Reply from 172.18.4.167: bytes=32 time=1ms TTL=128
Reply from 172.18.4.178: bytes=32 time=1ms TTL=128
Reply from 172.18.4.180: bytes=32 time<1ms TTL=128
Reply from 172.18.4.181: bytes=32 time=1ms TTL=128
Reply from 172.18.4.182: bytes=32 time<1ms TTL=64
Reply from 172.18.4.184: bytes=32 time=1ms TTL=64
Reply from 172.18.4.191: bytes=32 time<1ms TTL=128
Reply from 172.18.4.192: bytes=32 time=2ms TTL=64
Reply from 172.18.4.194: bytes=32 time<1ms TTL=128
Reply from 172.18.4.195: bytes=32 time=2ms TTL=64
Reply from 172.18.4.197: bytes=32 time=1ms TTL=255
Reply from 172.18.4.198: bytes=32 time=2ms TTL=128
Reply from 172.18.4.199: bytes=32 time=2ms TTL=128
Reply from 172.18.4.200: bytes=32 time=1ms TTL=128
Reply from 172.18.4.204: bytes=32 time<1ms TTL=128
Reply from 172.18.4.206: bytes=32 time=1ms TTL=128
Reply from 172.18.4.214: bytes=32 time<1ms TTL=128
Reply from 172.18.4.221: bytes=32 time<1ms TTL=128
Reply from 172.18.4.223: bytes=32 time<1ms TTL=128
Reply from 172.18.4.233: bytes=32 time=1ms TTL=128
Reply from 172.18.4.238: bytes=32 time=1ms TTL=128
Reply from 172.18.4.241: bytes=32 time<1ms TTL=128
Reply from 172.18.4.244: bytes=32 time=6ms TTL=64
Reply from 172.18.4.248: bytes=32 time=1ms TTL=128
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

dsterlingAuthor Commented:
Great, thank you
0
Harper McDonaldCommented:
Cool glad to help!
0
Harper McDonaldCommented:
There are also freeware tools from SolarWinds that can help you with what you are trying to do..
0
Steve KnightIT ConsultancyCommented:
BTW in a batch can just do a loop.  For command line use %a, if in batch file you use an extra % to make %%a.  You can get fancier but most basic this will loop %a from 1 to 254:

for /l %a in (1,1,254) do @ping 192.168.1.%a -n 1 -w 50

Useful when you only have basic stuff available to find what is online.

(for /l %a in (1,1,254) do @ping 192.168.1.%a -n 1 -w 50) > ping.txt
arp -a >> ping.txt
start ping.txt

etc.

Steve
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Networking

From novice to tech pro — start learning today.