24 March 2019

Remove .local address before O365 Migration

I was recently performing an O365 migration for a client who had lots of domain.local aliases.
There was no policy enforcing these addresses, and their accounts weren't picking up email address policies either.

The best way to find out who's got the .local address and then remove it is by running the following commands/scripts:

get-mailbox | where {$_.emailaddresses -like “*domain.local*”}

This will show you who has the domain.local address.  Once you've worked this out, you can then run the following script, which will go through and make sure that address is completely deleted from each mailbox alias.

$users = get-mailbox | where {$_.emailaddresses -like “*domain.local*”}
foreach ($user in $users)
$addresses = (get-mailbox $user.alias).emailaddresses
$fixedaddresses = $addresses | where {$_.proxyaddressstring -notlike “*domain.local”}
set-mailbox $user.alias -emailaddresses $fixedaddresses

The bold sections is where you need to update the domain name to whatsoever your .local address is.

1 comment: