Discussion Locked

Batch - PING list of computers (dynamic)

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I want to create a DOS Batch File that will automate a PING process for workstations listed in the Computers OU of Active Directory. There are around 4000 computer listings in this OU and I would like a script to PING all of these computer names and output the results to a file so it can be sorted through to determine which systems are from what subnets (and offices).

You can easily export the list of the Computers OU from Active Directory to a CSV file and resave
this into a text format.But, how to get this process to work properly?

FOR %%i IN (A1 A2 A3 A4 ...) DO PING %%i >> RESULTS.TXT

But, I don't want to list 4000 individual workstations for parameters and I would like the variable parameter to be dynamic and point to a source file (computers.txt) for the computer listing - which can be changed and updated, so this batch file can be run again at a later time for new results.

Any ideas how to make this work? Is there a different command that should be used?

Bonus Question: A way to parse the results into organized subnet listings, so not to have to do
any "manual sifting" through the results file

Thanks.

9 replies

by sgt_shultz

check out 3com website, i have software here that looks like it came free with my nic that does the mass pinging you want...you can specifiy subnets ... is called '3com net supervisor', maybe you can download it? or search for similar utilities on www.tucows.com or www.zdnet.com or your favorite download site? maybe you don't have to reinvent the wheel here...

by cactus pete

Instead of listing each computer in the (...), give the filename of your computers.txt, depending on how you're running it, you may want the path there, too. Just make sure that when you convert to the txt file, each computername is on its own line.

You will also probably want to use "ping -n 1" to keep the output more manageable.

As for grouping subnets, do that before you create the txt file. The batch file will wait for one ping to finish before starting the next one, so they will all be in order.

If this turns out to be less useful than you expected, and the 3com utility isn't working for you either, consider approaching a junior programmer who might be working in your company aand see if your bosses will let you work together to make your very own utility.

by joseph moore

This will work from a BAT file:

for /f "tokens=1-3 skip=3 delims=\ " %%i in ('net view') do ping %%i >>RESULTS.TXT

Run this from a Domain Controller. Also, you might want to put a DEL RESULTS.TXT in the BAT file BEFORE you run this FOR statment so you start out with a clear TXT file for later analyis.

hope this helps

This discussion is closed to new replies.