Get a list of all email addresses in your Exchange organization

Once in a while someone asks me for a list of all email addresses on the system. It might be for reporting, auditing, or whatnot, or maybe the boss is just curious. Whatever the reason is, here’s a short script that will get you a bare list of all addresses, minus resource mailboxes, shared mailboxes, and SIP addresses:

 

[PS] C:\windows\system32>$AllMailboxes = (Get-Mailbox -ResultSize unlimited | Where-Object {$_.IsResource -eq $False -and $_.IsShared -eq $False})
[PS] C:\windows\system32>$AllMailboxes | Select -expand EmailAddresses | where {$_.PrefixString -eq “smtp”} | select SmtpAddress | Export-Csv c:\temp\CurrentEmails.csv -NoTypeInformation

 

This will create a csv file listing all “user” smtp addresses without any other information, such as usernames, display names, etc.

A few notes:

  • If you have a lot of mailboxes, you’ll need to use the “-ResultSize unlimited” option to make sure you get them all. Otherwise, you’ll only get the first 1000 mailboxes.
  • If you want to include Resource and Shared mailboxes in your report, just remove this text from the first command: “| Where-Object {$_.IsResource -eq $False -and $_.IsShared -eq $False}”.
  • The -NoTypeInformation option after Export-Csv removes this irritating bit of text that would otherwise be at the top of your csv file and interfere with sorting:
    #TYPE Selected.Microsoft.Exchange.Data.SmtpProxyAddress

2 responses to “Get a list of all email addresses in your Exchange organization”

  1. Mike says:

    This is great! Many thanks for posting this code.

    We have multiple email domains that we accept mail for and I’d like to create separate CSVs for each domain. I have yet to figure out how to split it up.

    Any ideas would be fantastic!

  2. jay c says:

    You’re welcome, Mike. Thanks for the comment.

    For a quick and dirty solution, I’d try to get a list of accepted domains and run it through a foreach loop against these commands.

Leave a Reply

Your email address will not be published. Required fields are marked *