Need Tool/Command to return all members of a distribution group with email addresses
Got a DL in AD contains 300 users in Exchange 2003, i need a tool or command which can give me a list of all the 300 users with there email addresses in Excel format.I tryed ldifde, csvde and adfind to get the required output, got the username but how i can add a syntax or command to get there email addresses as well.Please help.ThanksInderjit Inderjit
May 25th, 2009 3:20pm

You can use vbscript to export the the list of members recursively, use DN of DL in the script and use below line to add email address... outfile.writeline strSpaces & objMember.name& strSpaces & objMember.mail VBScript: Write Group Membership Information to a Text File http://exchangeshare.wordpress.com/2007/10/30/vbscript-write-group-membership-information-to-a-text-file/ Amit Tank | MVP Exchange Server | MCITP: EMA | MCSA: M | http://ExchangeShare.WordPress.com
Free Windows Admin Tool Kit Click here and download it now
May 25th, 2009 3:37pm

Amit,I modified the script as you suggested but its giving me an error message, could you have a look at it (Domain=test.corp.local, OU=Exchange Issues).----------------=========Script Code=========== - Determine variable Dim outfile-Create File System Object Space -Set fso = CreateObject(Scripting.FileSystemObject) - Define variable for Output file to write -set outfile = fso.createtextfile(Members.txt,true)on error resume nextCall the Function for Finding Group Membership including nested groupsstrGroupDN = CN=Exchange Issues,OU=Distribution Lists,OU=Exchange Objects,OU=System Management,DC=test,DC=corp,DC=local*****Give here DN of Group*****strSpaces = set dicSeenGroupMember = CreateObject(Scripting.Dictionary)outfile.writeline Members of & strGroupDN & :DisplayMembers LDAP:// & strGroupDN, strSpaces, dicSeenGroupMemberFunction DisplayMembers ( strGroupADsPath, strSpaces, dicSeenGroupMember)set objGroup = GetObject(strGroupADsPath)for each objMember In objGroup.Membersoutfile.writeline strSpaces & objMember.nameif objMember.Class = group thenif dicSeenGroupMember.Exists(objMember.ADsPath) thenoutfile.writeline strSpaces & objMember.name & strSpaces & objMember.mail ^ already seen group member & (stopping to avoid loop)elsedicSeenGroupMember.Add objMember.ADsPath, 1DisplayMembers objMember.ADsPath, strSpaces & , dicSeenGroupMemberend ifend ifnextEnd FunctionMsgBox Group Membership has been dumped to -Members.txt- file =========Script Code===========----------------------ThanksInderjitInderjit
May 25th, 2009 3:44pm

Amit,I downloaded the originial script from http://www.microsoft.com/technet/scriptcenter/csc/scripts/ad/groups/cscad109.mspxand have only modified the DN in the file but that also giving me an error message that something on Line 19 Char 51 Error: Expected end of Statement, code 800A0401.Could u have a look at it pls.ThanksInder------------------' --------------------- Determine variable ---------------------------------------Dim outfile '------------------------Create File System Object Space --------------------------Set fso = CreateObject("Scripting.FileSystemObject") ' ------------------------- Define variable for Output file to write -----------------------------set outfile = fso.createtextfile("Members.txt",true) on error resume next'-------------Call the Function for Finding Group Membership - including nested groups--------------- strGroupDN = "CN=Exchange Issues,OU=Distribution Lists,OU=Exchange Objects,OU=System Management,DC=test,DC=corp,DC=local" '*****Give here DN of Group*****' strSpaces = " "set dicSeenGroupMember = CreateObject("Scripting.Dictionary")outfile.writeline "Members of " & strGroupDN & ":"DisplayMembers "LDAP://" & strGroupDN, strSpaces, dicSeenGroupMember Function DisplayMembers ( strGroupADsPath, strSpaces, dicSeenGroupMember) set objGroup = GetObject(strGroupADsPath) for each objMember In objGroup.Members outfile.writeline strSpaces & objMember.name if objMember.Class = "group" then if dicSeenGroupMember.Exists(objMember.ADsPath) then outfile.writeline strSpaces & " ^ already seen group member " & "(stopping to avoid loop)" else dicSeenGroupMember.Add objMember.ADsPath, 1 DisplayMembers objMember.ADsPath, strSpaces & " ", dicSeenGroupMember end if end if nextEnd Function MsgBox "Group Membership has been dumped to -Members.txt- file" Inderjit
Free Windows Admin Tool Kit Click here and download it now
May 25th, 2009 3:52pm

Ok, I just copied this from my master copy, check out and make sure that DL you are using it is Universal Group... The script at webpage has two lines combined so getting error at line 19... ' --------------------- Determine variable --------------------------------------- Dim infile,Ifname,InRec,Cname,log,shellfile,CSpace Const ForReading = 1, ForWriting = 2, ForAppending = 8 '------------------------Create File System Object Space -------------------------- Set fso = CreateObject("Scripting.FileSystemObject") ' ------------------------- Define variable for Output file to write ----------------------------- set outfile = fso.createtextfile("members.txt",true) on error resume next '------------------------------Call the Function for Finding Group Membership - includeing nested groups------------------------------ strGroupDN = "CN=Exchange Issues,OU=Distribution Lists,OU=Exchange Objects,OU=System Management,DC=test,DC=corp,DC=local" ' *****Give here DN of Group*****' strSpaces = " " set dicSeenGroupMember = CreateObject("Scripting.Dictionary") outfile.writeline "Members of " & strGroupDN & ":" DisplayMembers "LDAP://" & strGroupDN, strSpaces, dicSeenGroupMember Function DisplayMembers ( strGroupADsPath, strSpaces, dicSeenGroupMember) set objGroup = GetObject(strGroupADsPath) for each objMember In objGroup.Members outfile.writeline strSpaces & objMember.name & vbtab & objMember.mail if objMember.Class = "group" then if dicSeenGroupMember.Exists(objMember.ADsPath) then outfile.writeline strSpaces & " ^ already seen group member " & "(stopping to avoid loop)" else dicSeenGroupMember.Add objMember.ADsPath, 1 DisplayMembers objMember.ADsPath, strSpaces & " ", dicSeenGroupMember end if end if next End Function MsgBox "Group Membership has been dumped to Group Members.txt file" Amit Tank | MVP Exchange Server | MCITP: EMA | MCSA: M | http://ExchangeShare.WordPress.com
May 25th, 2009 4:06pm

Works perfectly and gave me the desired result but another question for you is "This DL contains some NON-Domain users as well, like some contacts have been added into this, is there a way to get those users/email address as well?Thanks a lot.InderjitInderjit
Free Windows Admin Tool Kit Click here and download it now
May 25th, 2009 5:00pm

Contacts should be included into output result, didn't those? Amit Tank | MVP Exchange Server | MCITP: EMA | MCSA: M | http://ExchangeShare.WordPress.com
May 25th, 2009 5:03pm

I see all users from my domain only in the output file, I think first I need to find out whats the total number of users i have in the DL and do the comparison between the output and the number I think that can help us to get the better picture...so question for you is "How I can find out the total number of users in a DL"Thanks bunch for helping me Amit.InderInderjit
Free Windows Admin Tool Kit Click here and download it now
May 25th, 2009 5:06pm

Okay, another simple way to find list of members (but not recursively for nested groups) and count...Open ADU&C -> Right Click on Saved Query and New Query -> Give Name, select DefineQuery -> in Find select Custom Search -> click Advance and write below query in "Enter LDAP Query" text box.... Click OK, OK and you get the desired result (members and total count), you can export too by selecting desired columns from View menu Add/Remove columns....(memberOf= CN=Exchange Issues,OU=Distribution Lists,OU=Exchange Objects,OU=System Management,DC=test,DC=corp,DC=local)Amit Tank | MVP Exchange Server | MCITP: EMA | MCSA: M | http://ExchangeShare.WordPress.com
May 25th, 2009 5:15pm

Sweet, wonderful MAN, thanks a lot for your help, got everything working...Take Care and Best of Luck ahead.InderjitInderjit
Free Windows Admin Tool Kit Click here and download it now
May 25th, 2009 5:20pm

Sweet, wonderful MAN, thanks a lot for your help, got everything working...Take Care and Best of Luck ahead.Inderjit Inderjit You are welcome...! Thanks and same to you... Amit Tank | MVP Exchange Server | MCITP: EMA | MCSA: M | http://ExchangeShare.WordPress.com
May 25th, 2009 5:23pm

Amit,Another small doubt I have is "if I forward the output to the csv file and want name in one and email in another column is there anything can be edited in the script which can give me that output as well.ThanksInderjitInderjit
Free Windows Admin Tool Kit Click here and download it now
May 25th, 2009 5:24pm

Well, it requires bit more coding with vbscripting....Rather, Open Excel (yes first open Excel), File -> Open -> Select members.txt file, in Text Import wizard select "start import at row" =2, next, next... that's all... users in first column and emails in second column.... Amit Tank | MVP Exchange Server | MCITP: EMA | MCSA: M | http://ExchangeShare.WordPress.com
May 25th, 2009 5:32pm

cool, got the desired output.Thanks Bro.InderInderjit
Free Windows Admin Tool Kit Click here and download it now
May 25th, 2009 5:37pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics