Solved

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

Posted on 2004-10-18
5
870 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 250 total points
ID: 12342711
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
ID: 12561214
Accept BlueDevilFan http:#12342711
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

726 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