1

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.

sysadmin1138
  • 133,124
  • 18
  • 176
  • 300
TheCleaner
  • 32,627
  • 26
  • 132
  • 191

4 Answers4

8

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
pk.
  • 6,451
  • 2
  • 42
  • 63
  • 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
1

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

did the trick for me!

Michael
  • 11
  • 1
0

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.

mfinni
  • 36,144
  • 4
  • 53
  • 86
  • 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
0

Here is another alternative to obtain the list of primary and secondary SMTP addresses of the mailboxes:

Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,PrimarySmtpAddress, @{Name="EmailAddresses";Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq "smtp"} | ForEach-Object {$_.SmtpAddress}}}

Extracted from: https://www.sysadmit.com/2018/04/exchange-exportar-direcciones-smtp.html