Connection/Ping check of only computers in computer OU, not a sweep, but only computers in OU.

I want to do a connection check on all the computers in our computer OU, I've been using Solarwinds ping sweep to ping a range of IPs, but when I do this I have to check all the IPs that don't reply against all the computers in our OU and its time consuming, I'd like to do a ping/connection check to only computers in our OU, does anyone know a way to do this (script, etc..) I'd prefer not to have to buy a utility for this.

Server 2003, XP Pro network environment.

It does not have to be a ping, but some way to checking if the computers are connected to the network. i.e. maybe exporting all computes in the OU to a file and using a script that will point to the exported file that will ping every computers in the file.

Thank you,
DSterling
dsterlingAsked:
Who is Participating?
 
MarcSpencerCommented:
Simply change the For line to

FOR /F "Tokens=2 Delims=cn=," %%i in (computers.txt) DO ping -n 3 -w 200 %%i >> PingResults.txt
0
 
MarcSpencerCommented:
From a script do a DS query to get computer names from the OU.

the use a for loop to run a ping process against each name in the DSquery...

You could also then output the results to a file, or multiple files based on computer name.
0
 
MarcSpencerCommented:
You could use something to the effect of the code below, to be able to use it for mulitple departments. You may need to change the ou container location to suit your AD structure.



@echo off
dsquery computer OU=Computers,DC=domain,DC=com -name >> computers.txt
FOR /F "Tokens=2 Delims=cn=," %%i in (computers.txt) ping %%i >> %%i-PingResults.txt

Open in new window

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
dsterlingAuthor Commented:
MarcSpencer,

Thank you for the answer, but its not working, it may be because the computer OU is a sub OU so I'm not sure how to apply that to the dsquery? also I'm not sure of the DC=com -name? can you eleberate on this?

Thank you
0
 
dsterlingAuthor Commented:
I was able to get dsquery to create a text file of all computers in our computer OU, but I can't figure out how to get the rest of the script to work so it will ping all computers in the created .txt file?
0
 
MarcSpencerCommented:
My Bad :)

Use the script below. The one above was written too late last night :)

@echo off
dsquery computer OU=Computers,DC=domain,DC=com -limit 10000 >> computers.txt
FOR /F "Tokens=2 Delims=cn=," %%i in (computers.txt) DO ping %%i >> %%i-PingResults.txt
 
If you want to make it run a little faster if you have many unconnected hosts change the ping for line to 
 
FOR /F "Tokens=2 Delims=cn=," %%i in (computers.txt) DO ping -n 3 -w 200 %%i >> %%i-PingResults.txt
 
Basically this line will only try and ping the host 3 times instead of 4. It will also tie out after 200ms instead of the default 1 second.
 
You can change this down to 2 but it wouldn't suggest changing it to 1 if you are trying to contact hosts across routers. Also don't drop the timeout period unless all hosts are on the same network and don't need to transverse routers.

Open in new window

0
 
dsterlingAuthor Commented:
MarSpencer,

I have the script working now, but the problem is that there is a .txt file created for every computer in our computer OU. Any computers that don't reply still have a .txt file created and in order to see what computers don't reply to the ping I have to open every file, this is much slower then the old way I was doing things. Is there a way to modify the script so the it will put the results in one text file?

Thank you,
DSterling
0
 
dsterlingAuthor Commented:
Works great!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.