• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 878
  • Last Modified:

Need a VB Script to List all Groups and the OU they are in

Hi,

I want to write a VBS script to get a listing of all Groups in the domain along with the OU that they belong to.

I know how to get the Group.Name, how can I a get a listing of all the information that would be available under that object?

Thanks
0
praflik
Asked:
praflik
  • 2
1 Solution
 
David LeeCommented:
Here you go.  The VBScript below will loop through all the OUs in the path specified and print out the names of the groups and the OU they were found in.  All you need to do is edit the first line and put in your LDAP path.  The script echos the information out so unless you want to have to keep hitting Return I suggest you run it with Cscript instead of Wscript.


---- BEGIN SCRIPT ----
ProcessOU "LDAP://server.company.com/dc=company,dc=com"
Wscript.Quit

Private Sub ProcessOU(strADSPath)
    Dim objAD
    Dim objOU
    Set objAD = GetObject(strADSPath)
    objAD.Filter = Array("OrganizationalUnit")
    SearchForGroups objAD.ADsPath, objAD.Name
    For Each objOU In objAD
        ProcessOU objOU.ADsPath
    Next
End Sub

Private Sub SearchForGroups(strADSPath, strOUName)
    Dim objOU
    Dim objGroup
    Set objOU = GetObject(strADSPath)
    objOU.Filter = Array("group")
    For Each objGroup In objOU
      Wscript.Echo "Group=" & Mid(objGroup.Name,4) & Space(50 - Len(Mid(objGroup.Name,4))) & strOUName
    Next
End Sub
0
 
David LeeCommented:
Accept BlueDevilFan http:#12342711
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now