Export members of distribution lists

Export members of distribution lists

Post by alton » Sat, 21 Jun 2003 07:36:35

Is there a way to them to either excel or text files for documentation
purpose?  Thank you.

Export members of distribution lists

Post by Dave Mill » Sat, 21 Jun 2003 16:04:54

Paste this code into a file called dumpdl.vbs, edit the lines towards the
top to reflect your domain name and the list name you want to dump, and the
run "cscript.exe dumpdl.vbs".  Note that this code won't handle groups with
membership over 1000 (you'll just get the first 1000 members).

---- START ----
Option explicit
Dim oConn

const strBaseDN = "dc=domain,dc=com"
const strListName = "listnamehere"


' Function GetObjectDN
Function GetObjectDN(strQuery)
Dim strResult
Dim rs

  strResult = ""

  Set rs = oConn.Execute("<LDAP://" & strBaseDN & ">;" & strQuery &

  If Not rs.eof Then
    strResult = rs.Fields("distinguishedName").Value
    Set rs = nothing
    GetObjectDN = strResult
    Exit Function
  End If

  Set rs = Nothing
  GetObjectDN = strResult
End Function ' GetObjectDN

Sub Main
Dim oRS
Dim oList
Dim oUser
Dim arrMembers
Dim i

  Set oConn = CreateObject("ADODB.Connection")
  oConn.Open "Data Source=Active Directory Provider;Provider=ADsDSOObject"
  Set oList = GetObject("LDAP://" & GetObjectDN("(mailNickName=" &
strListName & ")" ) )
  arrMembers = oList.Get("member")
  for i = 0 to uBound(arrMembers)
    Set oUser = GetObject("LDAP://" & arrMembers(i))
    wscript.stdout.writeline(oUser.Get("mailnickname") & " - " &
    Set oUser = Nothing

  Set oConn = Nothing
End Sub
----- END ----

Alternatively, you can look into using LDIFDE or CSVDE, but I'm not sure
what their behavior is when they dump list membership.

- Dave

Quote:> Is there a way to them to either excel or text files for documentation
> purpose?  Thank you.


1. Exporting members of distribution list to CSV file


I need to export members of a certain distribution list to a file,
preferably a CSV file. I have a script I found on the MS website which shows
me how to loop through a specified distribution list and display the users,
but I need this to end up in a file, and ideally showing just the users
display name.

Here's the script I got from MS :

Set objGroup = GetObject _
For each objMember in objGroup.Members
    Wscript.Echo objMember.Name

Anyone know how to adapt this to do what I want? I really don't know a lot
about this stuff, although I can code in VBScript with no problems....



2. Outlook Web Access install error

3. Export list of distribution lists members

4. Public Folder Access

5. exporting and importing distribution list members

6. Server went down.. Now IMS wont work.

7. Export Distribution List member info

8. ADSI: Domain

9. exporting distribution list members

10. Export of Distribution Lists and Members

11. Export list of Distribution group members

12. export distribution list members to a txt file

13. export members from a distribution list