Powershell Remove Non-Routable proxyaddresses for mailbox migration to Exchange Online

When doing a migration from onrem to Exchange Online / Office 365, the proxy addresses on the mail object must all be internet routable. If you have aliases like @domain.local, these need to be removed before the mailbox can be moved.

I used this powershell script to accomplish this in my environment:


Remove nonroutable smtp aliases in preparation for mailbox migration
Long description
remove-nonRoutableSmtpAddresses -Searchbase "OU=OrgUnit,DC=Domain,DC=com" -smtpsuffix "nonroutable.domain" -Verbose
function remove-nonRoutableSmtpAddresses
# Search base of users to search for

# SMTP suffix to find and remove

$smtpsuffix = ("*" + $smtpsuffix + "*")
$users = get-aduser -Filter {proxyaddresses -like $smtpsuffix} -Properties proxyaddresses -SearchBase $Searchbase
foreach ($u in $users){
Get-ADUser $u -Properties proxyaddresses `
| foreach {$pr = $_.proxyaddresses -like $smtpsuffix}
set-aduser $u -Remove @{proxyaddresses=$pr} -verbose

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s