Tech Blog‎ > ‎

List All Valid Email Addresses in Exchange 2007

posted Sep 6, 2011, 8:13 AM by Victor Zakharov   [ updated Sep 19, 2011, 1:32 PM ]
You may need these to configure your 3rd party antispam software/appliance. 
There were lots of articles on the internet with complicated solutions, which did not work for me. 
Here a Powershell one-liner for Exchange management shell: 

Get-Mailbox | foreach { $_.EmailAddresses | foreach { $_.SmtpAddress } }

Within regular Powershell, add this line at the very start:

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin

If you plan to run it as a batch job, the whole script could look like the following:

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
Get-Mailbox | foreach { $_.EmailAddresses | foreach { $_.SmtpAddress } } > emails.txt
Comments