Scripting Blog [archived]

Formerly known as the "Hey, Scripting Guy!" blog

Latest posts

How Can I Enumerate All the Objects in an Active Directory OU?
Sep 2, 2004
0
0

How Can I Enumerate All the Objects in an Active Directory OU?

ScriptingGuy1
ScriptingGuy1

Hey, Scripting Guy! How can I enumerate all the objects in an Active Directory OU?-- RB Hey, RB. By the way, thanks: it’s always nice to get an easy question every once in awhile! Enumerating all the objects in an OU is almost embarrassingly-simple: by default, any time you bind to an OU using ADSI you automatically get back a collection of all the objects in that OU. To enumerate those objects, all you have to do is create a For Each loop that walks through the collection. Don’t believe us? Well, here’s a script that binds to the Servers OU in a domain named fabrikam.com. After making the connection, the script...