Link to home
Start Free TrialLog in
Avatar of c7oi
c7oiFlag for United States of America

asked on

How to extract users and group from a Active Directory Distribution List to a CSV format?

I am trying to export the member and groups of my Distribution List to a CVS format,  How do I do it?
ASKER CERTIFIED SOLUTION
Avatar of Mike Kline
Mike Kline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is a scripts that builds a date based name.


------
Dim tsDate
Dim tsTime

tsDate = Year(Now) & "-" & Month(Now) & "-" & Day(Now) & Hour(Now) & "-" & Minute(Now) & "-" & Second(Now)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile_ADBackup  = objFSO.CreateTextFile("S4-Users-" & tsDate & "AllData.txt", 2)
Set objFile_ADBackup2 = objFSO.CreateTextFile("S4-Users-" & tsDate & "EmailOnly.txt", 2)
Set objShell = WScript.CreateObject("WScript.Shell")



'=========================================================================================
'Backup S4_Users Group before refreshing...
'=========================================================================================
'
'district.k12.fl.us/STUDENT/SCHOOLS/SPECIAL/BAC-9001/*Security Groups/S4_Users
'
Set objGroup = GetObject("LDAP://cn=S4_Users,ou=*Security Groups,ou=BAC-9001,ou=SPECIAL,ou=SCHOOLS,ou=STUDENT,dc=district,dc=k12,dc=fl,dc=us")
For Each objMember in objGroup.Members
    objFile_ADBackup.WriteLine objMember.sAMAccountName & "@mail.district.k12.fl.us" & chr(09) & objMember.ADsPath
    objFile_ADBackup2.WriteLine objMember.sAMAccountName & "@mail.district.k12.fl.us"
Next

objFile_ADBackup.Close
Avatar of michaelalphi
michaelalphi

Hi C7oi,
You can try this free tool (http://www.lepide.com/active-directory-query.html) to export the member and groups of your distribution list in CSV format.