Extracting Distribution List information in Exchange
Modify the values:
strServerGC="SERVERNAME"
strDN="dc=ROOT,dc=com"
strFileName="dl-dn-dump.txt"
Use following Script
'Script dumps all DL Names, DL Restrictions, Mananged by and number
' of members including Query-based to a text file
' separated by semi-colons. Open in Excel for easy formatting
strServerGC="SERVERNAME"
strDN="dc=ROOT,dc=com"
strFileName="dl-dn-dump.txt"
' Create file
Set objFSO = CreateObject("Scripting.FileSystemObject")
'If objFSO.FileExists("dl-Restriction-dump.txt") Then
' objFSO.DeleteFile("dl-Restriction-dump.txt")
'End If
Set dlDumpFile = objFSO.CreateTextFile(strFileName,true)
dlDumpFile.writeline "DL Name;Restriction Set;Resticted To;Managed By;Number of Members"
'Initailize DB Conneciton
set objConn=CreateObject("ADODB.Connection")
objConn.Provider="ADSDSOObject"
objConn.Open
set objRS=objConn.Execute _
("<LDAP://" & strDN & " >;(&(|(objectclass=Group)(objectClass=msExchDynamicDistributionList))(mailNickname=*));" _
& "ADsPath;SubTree")
while not objRS.EOF
set objGroup=GetObject(objRS.Fields("adspath"))
'wscript.echo objGroup.displayName
ProcessUsers(objGroup)
objRS.moveNext
Wend
function getDisplayName(objDN)
Set objGroup=GetObject("LDAP://" & strServerGC & "/" & objDN)
DisplayName=objGroup.DisplayName
getDisplayName=DisplayName
End Function
Sub ProcessUsers(objUsers)
On Error Resume Next
countMems = 0
'wscript.Echo objUsers.Name
set objPD = GetObject("LDAP://"& _
objUsers.distinguishedName)
groupName = objPD.displayName
groupManager = getDisplayName(objPD.managedBy)
delegateList = objPD.GetEx("authOrig")
'Users allowed to send
For Each Desc In delegateList
displayName=getDisplayName(Desc)
authList=authList & displayName & ","
Next
'DL's allowed to send
dlMemList = objPD.GetEx("dLMemSubmitPerms")
For Each dlMem In dlMemList
dlDName=getDisplayName(dlMem)
dlAuthList = dlAuthList & dlDName & ","
Next
'Number of members
numOfMembers = objPD.GetEx("member")
For each Mem In numOfMembers
countMems = countMems+1
'Uncomment memNames to add member names to the export
'memNames getDisplayName(Mem)
Next
set objPD = Nothing
if len(authList)>5 OR len(dlAuthList)> 5 then
restrictionSet = "Yes"
end if
dlDumpFile.writeLine groupName & ";" & restrictionSet & ";" & authList & dlAuthList & ";" & groupManager & ";" & countMems ' & ";" & memNames
End Sub
-------------------------------------------------------------------------------------------------------------------------------------------------------


Nice work sandeep !!!
Reply to this
Thanks John !!
Reply to this
For exporting a single DL's members try this script:
csvde -f DLreport.txt -r "memberOf=cn=MyList,ou=Sales,dc=MyDomain,dc=co m" -l
sAMAccountName,displayName,mail
ldifde -f report.txt -r "memberOf=cn=MyList,ou=Sales,dc=MyDomain,dc=co m" -l
sAMAccountName,displayName,mail
You must specify the full distinguished name of the distribution group.
Then you can import this txt file in Excel, using comma as seprator in the sheer.
how to import this in excel: open excel-- data .. import .. .. then follow the instructions. Commnet your questions here.
Reply to this