Writing it this way is very inefficient. It would take
x queries to look for each computer where X is the number of OUs you want to
check since you can't tell AD "look only in these distinct OUs" unless you can
specify one single branch of the hierarchy that contains all of the OUs. As you
add more OUs in different branches, the script would get slower and
slower.
It would be much more efficient to query the computer and
then compare the DN of the computer to the OUs you are interested in. That way
most of the work is string comparison on the machine running the script.
Another possible method would be to return all computer DNs
for computers in the listed OUs and then compare those with string comparison to
the computers you have. This could have implications on your memory allocation
though if there are ALOT of machines in those OUs.
For instance, say you have 1000 computers to be checked
against 10 OUs in diseparate branches. The initial method you indicate would
require 10,000 queries. The first method I mentioned would require 1000
queries. The second method I mentioned would take 10 queries but would probably
require more RAM.
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jitendra Kalyankar
Sent: Tuesday, December 20, 2005 11:10 AM
To: ActiveDir@mail.activedir.org
Subject: [ActiveDir] Script to find Computers under particular OUs
I am trying to find a way to write script. The scenario is a bit like
this,
I have few OU under which there are Computers. I need to check if
computer names are supplied from the text file then it will have to
run
against those particular OUs. If it can find machine under those
particular
OUs then it will write something like found or not found depending
upon
the search result. I know how to query against entire AD but I am
looking
a way out where I can just supply or hardcode the OUs and it will
search
against those multiple OUs only and not entire AD. Any help in this
regard is much appreciated.
Sincerely,
J
Sincerely,
J