For a project I had to create a CSV file with all Mailboxes, their UPN and their Email addresses. Not a big deal since you can use the following command:
Get-Mailbox | Select UserPrincipalName,EmailAddresses
Exporting to a CSV is a default feature in PowerShell using the Export-Csv command, like this:
Get-Mailbox | Select UserPrincipalName,EmailAddresses | Export-Csv C:\Temp\Addresses.csv
Unfortunately this does not give the desired outcome. Since the EmailAddresses property is a multi-value property only the definition is exported and not the values and it will show up like this:
#TYPE Selected.Microsoft.Exchange.Data.Directory.Management.Mailbox
“UserPrincipalName”,”EmailAddresses”
“Michael@azurelabs.nl”,”Microsoft.Exchange.Data.ProxyAddressCollection”
This can be solved by creating a custom field and grab all values of the property, joined with a “,” character, like this:
Get-Mailbox | Select UserPrincipalName, @{Name='EmailAddresses'; Expression={$_.EmailAddresses -join ","}}
Combine this with the Export-Csv command:
Get-Mailbox | Select UserPrincipalName, @{Name='EmailAddresses'; Expression={$_.EmailAddresses -join ","}} | Export-Csv C:\Temp\Addresses.csv
And this will result in a proper CSV file:
Special thanks to Michel de Rooij, my living PowerShell repository.
One thought on “Export Email Addresses in Exchange 2013”