Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to query a specific OU or container in AD^

Posted on 2008-06-17
2
Medium Priority
?
1,026 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

877 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