Solved

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

Posted on 2004-10-18
5
864 Views
Last Modified: 2012-06-27
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
Comment
Question by:praflik
  • 2
5 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 250 total points
Comment Utility
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
 
LVL 76

Expert Comment

by:David Lee
Comment Utility
Accept BlueDevilFan http:#12342711
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now