Solved

How to query a specific OU or container in AD^

Posted on 2008-06-17
2
1,021 Views
Last Modified: 2012-05-05
Hi Experts,

I need to list all computer in AD but our computer are not in the defaut OU or container. How can I query at the right place?
Computers are under \\Domain\Internal\Computers
' Connect to domain and retrieve distinguish name.
	Set objRoot = GetObject("LDAP://RootDSE") 
	Set objDomain = GetObject("LDAP://" & objRoot.Get("DefaultNamingContext")) 
	' Build Query to list only computer names from AD.
	strQuery = "Select Name From '" & objDomain.ADsPath & "' where objectClass='computer'"

Open in new window

0
Comment
Question by:EricPelletier
2 Comments
 
LVL 18

Expert Comment

by:sk_raja_raja
ID: 21802532
run "csvde" againt the domain controller...you will be able to get all the computer objects in .csv
0
 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 total points
ID: 21802826
You can use the script from this article:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/dec04/hey1207.mspx

Just comment out lines 21, 22, and 24 to return all computers in the domain.

To list all computers under an OU and its sub-OUs use this script:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/oct05/hey1013.mspx

Change "user" to "computer" in line 15.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question