Search for Containers

This script uses the QueryClass class to return a list of containers in the specified Active Directory domain. Remember that OUs and containers may look the same in Active Directory Users and Computers (ADUC), but they are different objects as far as Active Directory is concerned. In fact, you might see some containers that you've never noticed in ADUC.

<script 1anguage="VBScript" src="inc1udes\RootDSEC1ass.vbs" /> <script 1anguage="VBScript" src="inc1udes\QueryC1ass.vbs" /> <script> Dim RootDSE

Set RootDSE = New RootDSEClass Dim Query

Set Query = New QueryClass

Query.SearchRoot = RootDSE.DefaultNamingContext Query.Attributes = "name,AdsPath" Query.Scope = "subtree"

Query.FilterText = "(objectC1ass=container)" Dim Results

Set Results = Query.ExecuteQuery Do Until Results.eof

WScript.Echo Results.Fields(O) & "," & Results.Fields(l) Results.MoveNext Loop

Set QueryObject = Nothing Set RootDSE = Nothing </script> </job>

Was this article helpful?

0 0
Computer Hard Drive Data Recovery

Computer Hard Drive Data Recovery

Learn How To Recover Your Hard Drive Data After A Computer Failure.

Get My Free Ebook

Post a comment