Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Exporting users from Groups

Posted on 2006-11-14
7
Medium Priority
?
167 Views
Last Modified: 2010-04-30
I have 25 distribution groups and over a period they have become nested with various users and groups. I would like to export to file the groups and there related users for checking and cleaning purposes.
Any ideas what i can use?
0
Comment
Question by:boomerbostock
  • 4
  • 3
7 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 18016274
I can do this with a bit of VB Script.  For each group member what information do you want to export?
0
 

Author Comment

by:boomerbostock
ID: 18016294
Firstly the users - Then the groups that have been nested in the DG and the users in those groups.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 18016367
Ok, but what information do you want?  Just names?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:boomerbostock
ID: 18016373
sorry yes
0
 
LVL 76

Accepted Solution

by:
David Lee earned 1500 total points
ID: 18016906
Try this.  It exports the members of the specified group to an Excel spreadsheet.  It drills down through any sub-groups to get all the members names.

Dim objGroup, objExcel, objSheet, iRow, objMemberPath, objMember
Set objGroup = GetObject("LDAP://CN=myDistList,ou=Messaging,dc=myDomain,dc=com")

Set objExcel = CreateObject("Excel.Application")
With objExcel
  .SheetsInNewWorkbook = 1
  .Workbooks.Add
  .Visible = True
  Set objSheet = .Worksheets.Item(1)
  .Worksheets.Item(1).Name = mid(objGroup.Name, instr(1,objGroup.Name,"=") + 1 ) 'set Worksheet name to that of the DL
  irow=1

 For Each objMemberPath in objGroup.Members
    Set objMember = GetObject(objMemberPath.ADsPath)
    If objMember.Class = "group" Then
        ProcessGroup objMember
    Else
        objSheet.Cells(iRow,1) = objMember.displayName
        irow=irow + 1
    End If
 Next
 .Columns(1).entirecolumn.autofit
End With

objExcel.ActiveWorkbook.SaveAs "C:\eeTesting\Group Members.xls"
Set objSheet = Nothing
Set objExcel = Nothing
Set objGroup = Nothing  
Set objMember = Nothing
Set objMemberPath = Nothing
WScript.Quit


Sub ProcessGroup(objGroup)
    Dim objMemberPath, objMember
    For Each objMemberPath In objGroup.Members
        Set objMember = GetObject(objMemberPath.ADsPath)
        If objMember.Class = "group" Then
            ProcessGroup objMember
        Else
            objSheet.Cells(iRow,1) = objMember.displayName
            irow=irow + 1
        End If
    Next
    Set objMemberPath = Nothing
    Set objMember = Nothing
End Sub
0
 

Author Comment

by:boomerbostock
ID: 18016950
ok I'll try
procedure? copy to notpad and save as xxx.vbs Yes?
0
 
LVL 76

Expert Comment

by:David Lee
ID: 18018088
Yes, that'll do it.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 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…
Suggested Courses

877 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