Use the following PowerShell script to export a list of email addresses into a CSV file. The file will containt displayName, primarySMTPAddress and emailAddresses (proxyAddresses).
{code lang:ini showtitle:false lines:false hidden:false}$tbldata = @()
$arrmbx = get-mailbox -resultsize unlimited
foreach ($mbx in $arrmbx ) {
$mailstring = ”
$record = @{}
[array]$SmtpProxyAddresses = $mbx.emailaddresses | Where {$_.prefixstring -like ‘smtp’} | sort IsPrimaryAddress -Descending
foreach ($mailadd in $SmtpProxyAddresses) {
$mailadd = $mailadd -replace “smtp:”
If ($mailstring -eq ” ) {
$mailstring = $mailadd
}
ELSE {
$mailstring += “,” +$mailadd
}
}
$record.displayName = $mbx.name
$record.primarySMTP = $mbx.primarySMTPaddress
$record.emailAddress = $mailstring
$tbldata += new-object PSObject -Property $record
}
$tbldata | Export-Csv “Email Addresses.csv” -NoTypeInformation
{/code}