Quantcast
Channel: Alex Who?
Viewing all articles
Browse latest Browse all 11

Unable to access mailbox using Outlook after remote mailbox move to Office 365

0
0

This really sucks, and you won't find out until the process has completely failed.

The breakdown is; you are migrating mailboxes, you go to complete (or auto-complete), and mailboxes get stuck with a move status of "InProgress". If your users are in mail they will get disconnected and not be able to reconnect. Now, you've told them this was the case (I'm sure), and so, as they have been told, they close Outlook and re-open, logging in with their UPN, but no dice. They complain, you check on-prem and they are still a UserMailbox so you tell them they are stupid and to get back to work, they will be migrated soon.

Time goes on and they still complain. Now you look in the service...hmm they show as UserMailbox there. You look on-prem and they are UserMailbox there too...oh shit. Now, if you wait around 4 hours (it tries around 400 times, iirc, or so to complete the conversion and it ends up taking around four hours) they will eventually fail and you will get the report showing something like:

Failed to convert the source mailbox 'blah.com\guid (Primary)'

What happened? Well, the source mailbox (your on-prem mailbox) was soft-deleted, the Exchange Online mailbox is live, but your on-prem environment has no clue this has happened. You now need to make that user into a remoteMailbox. Simple right? Just delete the mailbox and enable-remoteMailbox. Yes, it is that easy, but keep in mind the following:

Disabling a mailbox removes all mail attributes from the user account, this means when users try and send mail to the user after they are re-enabled as remote, email will bounce if they are using the cached entry in Outlook (both PC and Mac). Once in this situation how will you get the legacy ExchangeDN? In a haste to fix someone your typical admin will not think to dump all properties of the user mailbox, including the database they were on and the LEDN, before disabling the mailbox. What about any additional email addresses? They are gone. That’s the functional aspects, what about all of the data that we have stored in the custom attributes? Gone.

So, let's be smart about how we fix this. Take the easy approach and dump everything (get-mailbox $user | fl *) then piecemeal it back together. Or be even smarter and make yourself a sweet script.

After this happened once during one of our migrations I threw this together for the Ops guys to quickly get the users working again. Or do what Microsoft says (https://support.microsoft.com/en-us/kb/2745710).

The script does the following:
- grabs the list of users you want to work on (I usually use email address) as a single user or an array of users
- makes sure the user has a mailbox
- grabs email addresses and the legacy Exchange DN into some variables
- grabs some extension attributes
- deletes the mailbox
- enables the remote mailbox
- re-stamps all of the stuff we cared about

-enjoy

<#
.SYNOPSIS

Completes the mailbox conversion process for a failed migration to Office 365.

.DESCRIPTION

In some cases mailboxes will fail to convert completely to RemoteMailbox. When
this happens the on-prem mailbox is soft-deleted, but the user is not
updated to recipientType of RemoteMailbox.

This script will store the attributes we care about, disable the mailbox,
enable the user as a RemoteMailbox, and set back the attributes we care about.

.PARAMETER User

Fixes the specified user. Pass a single user, an array of users, or pipe in a
user or array.

.EXAMPLE
clean-failedmigration.ps1 -users

#>

param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[ValidateScript({get-recipient $_ })]
[string[]]
$Users
)

process{

foreach ($user in $users) {

if ($mbx = get-mailbox $user -ea silentlyContinue ) {

$allProxyAddresses = $mbx.EmailAddresses
$allProxyAddresses.add("X500:$($mbx.LegacyExchangeDN)")

$PrimaryEmail = $mbx.primarysmtpaddress.tostring()
$ExtEmail = $mbx.emailaddresses.smtpaddress | ? {$_ -like "*@blah.mail.onmicrosoft.com"}

if ($ExtEmail.count -gt 1) {
$ExtEmail = $mbx.alias + "@blah.mail.onmicrosoft.com"
}

$mbxObject = New-Object PSObject -Property @{
DN = $mbx.distinguishedname
Alias = $mbx.alias
ProxyAddresses = [string]$allProxyAddresses
LegacyExchangeDn = ("X500:$($mbx.LegacyExchangeDN)")
DisplayName = $mbx.displayName
ExtAttrib1 = $mbx.customattribute1
ExtAttrib2 = $mbx.customattribute2
ExtAttrib9 = $mbx.customattribute9
PrimaryEmail = $mbx.PrimarySmtpAddress
RemoteRoutingAddress = $ExtEmail
}

$mbxObject | fl *

$disableMBParams = @{
Identity = $mbxObject.DN
confirm = $True
}
Disable-Mailbox @disableMBParams | out-null

$enableMUParams = @{
Identity = $mbxObject.DN
primarysmtpaddress = $mbxObject.PrimaryEmail
RemoteRoutingAddress = $mbxObject.RemoteRoutingAddress
Alias = $mbxObject.alias
}
Enable-RemoteMailbox @enableMUParams

$remoteMbxParams = @{
Identity = $mbxObject.DN
EmailAddressPolicyEnabled = $True
CustomAttribute1 = $mbxObject.ExtAttrib1
CustomAttribute2 = $mbxObject.ExtAttrib2
CustomAttribute9 = $mbxObject.ExtAttrib9
}
Set-RemoteMailbox @remoteMbxParams
Set-RemoteMailbox -Identity $mbxObject.DN -EmailAddresses $allProxyAddresses
} else { write-host "$user is not a valid mailbox" -foreground red }
}

 


Viewing all articles
Browse latest Browse all 11

Latest Images

Trending Articles





Latest Images