Exchange Server stores user’s alternate email addresses as a multi-valued attribute within Active Directory. For example, if my colleague Jorge has jdiaz@demolab.local as well as diazj@demolab.local, his proxyAddresses attribute would look like this:

Notice, the capital SMTP vs. the lowercase smtp. There can be only one uppercase SMTP, and this represents the primary, or “reply to” address.
While, it’s very easy to view someone’s proxy addresses (often called aliases, but don’t confuse it with the “alias” attribute) within the Exchange Management Console, it can be tough to work with in the Exchange Management Shell (PowerShell) due to the data being stored as a “Multi-Valued” attribute. The usual “Get-Mailbox” output not only shows all addresses as a single item, but in the case “mcrowley” below, we can see the shell truncates:

While there are ways (example1, example2) to manipulate this output on the screen, I recently needed to create a complete list of all users possessing one or more secondary email address, and document what those addresses were.
On the surface, this sounds simple. We want a list of users who have more than 1 proxy address. At first, I thought of something like this:
Get-Mailbox -Filter {emailaddresses -gt 1} | Select EmailAddresses

But we can see this doesn’t actually capture the correct users. In the above example, LiveUser1 only has a single proxy address, but it was returned anyway. This is because the result is actually converted to a number, and the “-gt” or “greater than” operation is done on this number; not what we want.
To get the user collection you want, we actually need to break-out the data within this attribute, and evaluate it in a somewhat CPU intensive process. I have written a script that helps here, by doing the following things:
- Grabs all mailboxes and counts the number of proxy addresses for each one. I have filtered out X400, and other non-smtp addresses.
- If more than one proxy is found, it puts the user and it’s proxy addresses in a “nice” CSV file called c:\TooManyProxies.csv.
- Displays a similar output to the screen.
- Displays the total number of users found.
Here is a sample output, shown in excel (with some bolding on the headers):

The guts of this script might help with this exact scenario, or really, anywhere you want to break out and evaluate multi-valued attributes. Feel free to use it and adjust as you see fit!
Some known limitations:
- I’m no PowerShell master, so this might not be as efficient as it could be.
- If a user has more than 10 proxy addresses, you’ll need to adjust the script and add more rows.
- There isn’t a lot of error checking here, but I’ve used it in 2 different environments and it ran as expected.
As shown below, this script doesn’t differentiate “SMTP” from “smtp”. The addresses are listed in order stored; not necessarily relevant to us. If you want this information shown, remove this portion from the script:
If you ONLY want a csv of everyone’s proxy address, change “-gt 1″ to “-gt 0″
Finally, the script itself:
#ProxyAddressCount-v3.1
# by Mike Crowley http://mikecrowley.us
cls
Write-Host "Getting and evaluating users. Please wait; this could take a while..." -ForegroundColor Cyan
#Getting a list of mailboxes to work with
$UserList = Get-mailbox -Resultsize unlimited
$TooManyProxies = @()
foreach ($User in $UserList) {
#get a list of SMTP and smtp proxy addresses for each User
$SmtpProxyAddresses = (Get-Mailbox $User).emailaddresses | Where {$_.prefixstring -like 'smtp'}
#This section creates a lot of errors since many users don't have 3,4,5 etc proxy addresses. Here we turn error output off.
$ErrorActionPreference = 'SilentlyContinue'
#Create a new placeholder object so that we don't store the x400/x500 proxy addresses
$UserAndSmtpObject = New-Object PSObject -Property @{
Name = $user.name
SmtpAddresses1 =$SmtpProxyAddresses[0] -replace "smtp:"
SmtpAddresses2 =$SmtpProxyAddresses[1] -replace "smtp:"
SmtpAddresses3 =$SmtpProxyAddresses[2] -replace "smtp:"
SmtpAddresses4 =$SmtpProxyAddresses[3] -replace "smtp:"
SmtpAddresses5 =$SmtpProxyAddresses[4] -replace "smtp:"
SmtpAddresses6 =$SmtpProxyAddresses[5] -replace "smtp:"
SmtpAddresses7 =$SmtpProxyAddresses[6] -replace "smtp:"
SmtpAddresses8 =$SmtpProxyAddresses[7] -replace "smtp:"
SmtpAddresses9 =$SmtpProxyAddresses[8] -replace "smtp:"
SmtpAddresses10 =$SmtpProxyAddresses[9] -replace "smtp:"
}
#Turning error reporting back on
$ErrorActionPreference = 'Continue'
#Count the number of proxy addresses for each User
$SmtpProxyAddressCount = ($SmtpProxyAddresses).count
#Add Users with more than 1 proxy address to the $TooManyProxies variable
if ($SmtpProxyAddressCount -gt 1) {
$TooManyProxies += $UserAndSmtpObject
}
}
Write-Host ""
$TooManyProxies | select name, SmtpAddresses1, SmtpAddresses2, SmtpAddresses3, SmtpAddresses4, SmtpAddresses5, SmtpAddresses6, SmtpAddresses7, SmtpAddresses8, SmtpAddresses9, SmtpAddresses10 | Export-CSV c:\TooManyProxies.csv
$TooManyProxies | select name, SmtpAddresses1, SmtpAddresses2, SmtpAddresses3, SmtpAddresses4, SmtpAddresses5, SmtpAddresses6, SmtpAddresses7, SmtpAddresses8, SmtpAddresses9, SmtpAddresses10
Write-Host ""
#Display a count
Write-Host "You had" ($TooManyProxies).count "Users containing two or more proxy SMTP addresses." -ForegroundColor Cyan
Write-Host ""
Write-Host ""
Write-Host "Your result file is here 'c:\TooManyProxies.csv'" -ForegroundColor Cyan