Removing a ProxyAddress from Exchange 2010

This script was incredibly helpful for me in our Office 365 Migration as I needed to get rid of some addresses that would not be coming with us to the cloud. It gets rid of a ProxyAddress/secondary SMTP address in Exchange.  I’ve used this against Exchange 2010, but it would likely work for 2007, or 2013 as well. Copy everything in bold and make “” match your domain. This script requires a .txt file containing usernames (I used userprincipalnames). As you can tell, we’re looking for the file containing usernames at c:user.txt.

$Mailboxes = get-content “c:user.txt” | Get-Mailbox
$Mailboxes | foreach{
for ($i=0;$i -lt $_.EmailAddresses.Count; $i++)
$address = $_.EmailAddresses[$i]
if ($address.IsPrimaryAddress -eq $false -and $address.SmtpAddress -like “*” )
Write-host($address.AddressString.ToString() | out-file c:addressesRemoved.txt -append )
Set-Mailbox -Identity $_.Identity -EmailAddresses $_.EmailAddresses

As always, please use these scripts at your own risk, also as a best practice and learning exercise, do your best to understand these scripts prior to use.

Leave a Reply

Your email address will not be published. Required fields are marked *