Search This Blog

Tuesday, January 10, 2012

Print List of Groups in OU

Ref: http://blogs.technet.com/b/heyscriptingguy/archive/2005/09/21/how-can-i-list-all-the-groups-in-an-ou.aspx
Ref: http://www.devguru.com/technologies/vbscript/quickref/filesystemobject_createtextfile.html

Set objOU = GetObject("LDAP://OU=Users,OU=Groups,OU=City,OU=Work,OU=Dept,DC=xx,DC=yy,DC=zz")
objOU.Filter = Array("Group")

Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoFile = fso.CreateTextFile("C:\Windows\Temp\listgroupsinou.txt")

For Each objGroup in objOU
fsoFile.WriteLine(objGroup.Name)
' Wscript.Echo objGroup.Name
Next

fsoFile.Close

No comments: