Solved

How to query a specific OU or container in AD^

Posted on 2008-06-17
2
1,016 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
Comment Utility
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
Comment Utility
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 Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
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 tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now