Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a need to export ALL SMTP addresses that my Exchange organization has to a CSV file. This includes mailboxes, distribution lists, contacts, and public folder SMTP addresses.

I have to include all of the smtp adddresses associated with the above...not just the primary address.

I've found how to export the mailboxes to some extent, but it typically won't included 2nd or 3rd SMTP addresses if the user has them.

I haven't found anything though that can also export the SMTP addresses from the distribution lists, contacts, and public folders that are mail enabled.

I don't need CC Mail, etc. etc. just the SMTP addresses themselves. I'm trying to get a list of all "allowed SMTP addresses" for inbound spam filtering.

Please help...I'm going nuts trying to figure this out.

share|improve this question
up vote 8 down vote accepted

In Exchange Management Shell, run the following:

get-mailbox | %{$_.EmailAddresses} | %{$_.SmtpAddress} | out-file c:\mailboxes.csv
get-distributiongroup | %{$_.EmailAddresses} | %{$_.SmtpAddress} | out-file c:\distributiongroups.csv
get-contact | %{$_.WindowsEmailAddress} | %{$_.Local + "@" + $_.Domain} | out-file c:\contacts.csv
get-mailpublicfolder | %{$_.EmailAddresses} | %{$_.SmtpAddress} | out-file c:\mailpublicfolders.csv
share|improve this answer
This seems like it might work...but how can I pipe it to a CSV file? I tried running your first line for the mailboxes with "| Export-Csv C:\mailboxes.csv -NoTypeInformation" added to it but it didn't like that (errored out like crazy). It appears that " >> C:\mailboxes.csv" seems to work ok...just adds some formatting entries at the top. I can live with that if there isn't something simpler. – TheCleaner Mar 16 '11 at 22:01
I modified the commands to output to a file. See if that's what you're looking for. – pk. Mar 16 '11 at 22:11
pk - you rock. Perfection. – TheCleaner Mar 17 '11 at 13:32

csvde -d "DC=solid,DC=local" -f adusers.csv -l "displayname,mail,mailnickname,proxyaddresses"

did the trick for me!

share|improve this answer

You should do this from AD, not from Exchange. You can do a GUI query, you can use powershell or dsquery/dsget, or csvde/ldfide, to dump either everything from AD or just the attributes that contain the addresses. You might do best to just dump everything into a file and search for '@' and then sort/dedupe the list, unless you want to spend the time writing a script that does it perfectly. Unless you're going to be doing this often, I would do it the simple way of dumping everything and filtering the output file.

share|improve this answer
I'm fine with dumping everything and filtering, I'm just not sure what the commands are to dump everything that has an SMTP address. All I've really been able to find is for user accounts. (granted I've been lazy to look, but that's why I posted here! :)) – TheCleaner Mar 16 '11 at 21:15
I listed some of the commands. You can use the ADUC GUI or any other AD/LDAP query GUI like ADExplore, you could use dsquery and dsget, or you could used ldifde or csvde. – mfinni Mar 16 '11 at 21:19
Sorry, I meant I know about those commands, just not the syntax to get everything needed. I'm going to try pk's powershell commands first. – TheCleaner Mar 16 '11 at 21:58
CSVDE -f adusers.csv dumps everything. – mfinni Mar 16 '11 at 22:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.