List all valid email addresses in Exchange 2007
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