How can you obtain a list of the email addresses in a distribution list? If your version of Exchange does not have this functionality built-in, you can use one of the following options.
For the following, your domain is your_domain.com and the Active Directory organizational unit that contains the distribution list you want enumerated is Distribution Lists.
Run CSVDE, or if you prefer, LDIFDE. These are command line tools that can interact with directory objects. They are not included in the workstation versions of Windows (XP, Vista, 7) but they should be available on Windows Server versions. The following command would be entered on a single line. It wraps here for readability.
csvde -f Path\to\output\file.txt -r "memberOf=cn=distribution_list_name,ou=Distribution Lists,dc=your_domain,dc=com" -l "cn,mail"
The following VB script exports the names and email addresses of a given distribution list to an Excel spreadsheet. It can be run from any machine in the domain, no special permissions required. The core functionality of the script was taken from a forum post who’s location I forgot long ago. Note that you’ll need to change line #11 to reflect the ou and dc values appropriate to your environment.
Dim objDistList, objExcel, ExcelRow, strUser, strDistListName, strOU strDistListName = InputBox("Enter the name of the Distribution List" _ & " who's members you wish to export.", "Distribution List Export") If len(trim(strDistListName)) = 0 Then Wscript.Quit End If Set objDistList = GetObject("LDAP://CN=" & strDistListName _ & ",ou=Distribution Lists,dc=your_domain,dc=com") Set objExcel = CreateObject("Excel.Application") With objExcel .SheetsInNewWorkbook = 1 .Workbooks.Add .Visible = True .Worksheets.Item(1).Name = mid(objDistList.Name, _ instr(1,objDistList.Name,"=") + 1 ) ExcelRow=1 For Each strUser in objDistList.Member Set objUser = GetObject("LDAP://" & strUser) .Cells(ExcelRow,1) = objUser.CN .Cells(ExcelRow,2) = objUser.mail ExcelRow=ExcelRow + 1 Next .Columns(1).entirecolumn.autofit .Columns(2).entirecolumn.autofit End With Set objExcel = Nothing Set objDistList = Nothing Wscript.Quit
Not an IT guru? Just need a stinking list of email addresses and don’t know what the heck I’m talking about? Here’s what you do. Copy the code above and paste it into Notepad. Do not include the line numbers. On line 11 change your_domain and com to match the domain of your email address, e.g., company.corp, example.com, etc. Then save it with the name exporter.vbs (not .txt). Double-click on the file you just saved, and watch the magic happen. In the majority of cases, that’s all you’ll need to do.
You may find the following pages useful.
Introduction to CSVDE and LDIFDE – Article from computerperformance.co.uk
Scripts to Manage Active Directory Users – From ActiveXperts
Slick Powershell Script – Includes recursive functionality