troubleshooting Question

How do create a batch file that will ping all the computers from a file then create a new file with only those computers that respond?

Avatar of killefer762
killefer762 asked on
Networking
7 Comments1 Solution459 ViewsLast Modified:
I used dsquery to generate a file that contains the names of all computers in the domain.  Now i want to create a report that will contain only computers that respond to a ping.

Workstations.txt is a file with all my computers names in it.  This command does generate a new file with only the alive machines.

for /f %%a in (workstations.txt) do ping -a -n 1 %%a | find "TTL" >> HostsUp.txt

Here is a sample from the Hostsup.txt file:
Reply from 192.168.1.132: bytes=32 time<1ms TTL=128
Reply from 192.168.1.131: bytes=32 time<1ms TTL=128
Reply from 192.168.1.112: bytes=32 time<1ms TTL=128
Reply from 192.168.1.134: bytes=32 time<1ms TTL=128

What i really want is the HostsUp.txt file to have only the name (or ip) only and get rid of the rest of the info.

I want it to look this way:  (it could be the machine name - doesn't matter either way works)
192.168.1.132
192.168.1.131
192.168.1.112
192.168.1.134

Any help is very appreciated !!!








Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros