Ever have one of those really odd problems that even Google couldn’t solve? Last week, I spent a few hours reliving this xkcd comic:
I didn’t have it quite as bad as the guy in the comic. I had a nice detailed error and a partial solution from here. With a bit of tinkering and PowerShell, I now have a full solution to failed mailbox migrations from Exchange 2010 (or 2013) to Office 365.
Error Message:
Warning: The mailbox was already moved but failed to update the job state during the final stages of the move. It is possible that the source mailbox could still be alive since post move cleanup operations were deliberately not executed.
Symptoms:
- Migrated mailbox still appears in on premise exchange management console.
- User can’t receive external emails in OWA.
- User can’t receive internal emails in Microsoft Office Outlook.
Solution:
- Backup exchange attributes from on premise AD account.
- Disconnect the mailbox from on premise exchange environment
- Repopulate exchange attributes
- Set missing exchange attributes (most likely – only targetaddress attribute needs to be set. Compare to other successfully migrated users to double check).
- Wait for sync to Office 365 or force sync by running the following PowerShell line:
Start-ADSyncSyncCycle -PolicyType Delta
You can use PowerShell to automate all of this. Below is a sample script that I put together:
add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010 Import-Module ActiveDirectory $Username = "SadUsernameHere" $O365DomainName = "@OFFICE365DOMAINNAME.COM" $ADUser = Get-ADUser $Username -Properties * $Backup = Get-ADUser $Username -Properties * $TargetAddress = 'SMTP:' + $Username + $O365DomainName $Proxyaddresses = $ADUser | select -ExpandProperty proxyaddresses $mailNickname = $ADUser | select -ExpandProperty mailnickname $mail = $ADUser | select -ExpandProperty mail write-host $TargetAddress write-host $Proxyaddresses Write-Host $mailNickname Write-Host $mail pause Disable-Mailbox -Identity $username sleep -Seconds 5 Set-ADUser $Username -EmailAddress $mail -Replace @{mailNickname="$mailNickname";TargetAddress="$TargetAddress"} foreach ($Proxyaddress in $Proxyaddresses){ Write-Host $Proxyaddress Set-ADUser $Username -Add @{Proxyaddresses="$Proxyaddress"} }
The script above uses the Exchange 2010 PowerShell cmdlets. You will need to customize the $username variable and the $O365DomainName variable.
Here is a modified version of the script with some additional fields, including disabling the email address policy which could overwrite the targetaddress field.
add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
Import-Module ActiveDirectory
$Username = “SadUsernameHere”
$O365DomainName = “@OFFICE365DOMAINNAME.COM”
$ADUser = Get-ADUser $Username -Properties *
$Backup = Get-ADUser $Username -Properties *
$TargetAddress = ‘SMTP:’ + $Username + $O365DomainName
$Proxyaddresses = $ADUser | select -ExpandProperty proxyaddresses
$mailNickname = $ADUser | select -ExpandProperty mailnickname
$mail = $ADUser | select -ExpandProperty mail
$legacyExchangeDN = $ADUser | select -ExpandProperty legacyExchangeDN
write-host $TargetAddress
write-host $Proxyaddresses
Write-Host $mailNickname
Write-Host $mail
Write-Host $legacyExchangeDN
pause
Disable-Mailbox -Identity $username
sleep -Seconds 20
Set-ADUser $Username -EmailAddress $mail -Replace @{mailNickname=”$mailNickname”;TargetAddress=”$TargetAddress”}
Set-ADUser $Username –Replace @{legacyExchangeDN=”$legacyExchangeDN”}
Set-ADUser $Username –Replace @{msExchRecipientDisplayType = “-2147483642”}
Set-ADUser $Username –Replace @{msExchRecipientTypeDetails = “2147483648”}
Set-ADUser $Username –Replace @{msExchRemoteRecipientType = “4”}
Set-ADUser $Username –Replace @{msExchPoliciesExcluded = “{26491CFC-9E50-4857-861B-0CB8DF22B5D7}”}
foreach ($Proxyaddress in $Proxyaddresses){
Write-Host $Proxyaddress
Set-ADUser $Username -Add @{Proxyaddresses=”$Proxyaddress”}
}
Thank you for that, Eugene!
Dang it, my additional “Set-ADUser $Username” commands are using the wrong dash.
Set-ADUser $Username –Replace @{legacyExchangeDN=”$legacyExchangeDN”}
should be
Set-ADUser $Username -Replace @{legacyExchangeDN=”$legacyExchangeDN”}
Thanks for the correction, Eugene!
Hi!
I found that users ‘msExchRecipientTypeDetails’ was cleared after onprem mailbox disable.
So it should be reset to 2147483648 (Remote User mailbox)
Regards!
-J-P
Yes – set that. There are a few other attributes that I’ve found as well. You will need to populate them with the attributes values in your environment:
msExchMobileMailboxFlags
msExchPoliciesIncluded
msExchRecipientDisplayType
msExchRecipientTypeDetails
msExchTextMessagingState
msExchUserAccountControl
msExchVersion