Solved

How to query a specific OU or container in AD^

Posted on 2008-06-17
2
1,019 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

803 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