Home > Exchange, Office365, Powershell > [EXO][EX2010] Removing dual mailboxes

[EXO][EX2010] Removing dual mailboxes

Ensure you have a user mailbox backup prior to starting the following process as there is potential risk of data loss.  Options are to have a third party solution to perform a mailbox backup or export to PST (see new-mailboxexport cmdlet).

  1. Capture relevant information from on-premise exchange and exchange online.
    • Grab the mailbox information (primary and archive) to help determine which mailbox is active and which one to disable (remove)
      • get-mailboxstatistics <user>
      • get-mailboxstatistics <user> -archive
      • get-exomailboxstatistics (exo ps v2)
    • Grab the x500 address (legacydn)
    • Grab GUID information
      • get-recipient <user> | fl *guid*
  2. Determine which mailbox is active and which one to disable (remove) – 
    1. Removing the on-premise mailbox will require you to delete and recreate the remote mailbox – an object on-premise will need to represent the object on exchange for remote routing.
      1. Disable the on-premise mailbox – do not remove, or you will remove the AD user object:
        • disable-mailbox <user>
      2. If litigation hold is enabled, you will need to disable the hold, then disable the mailbox.
      3. Recreate the remote mailbox on-premise
        • Enable-RemoteMailbox -Identity <user> -RemoteRoutingAddress “<user>@<tenant>.mail.onmicrosoft.com”
      4. Associate the GUID and x500 for sync and mail routing:
        • Set-RemoteMailbox -exchangeguid <exchange guid> -archiveguid <archive guid>  -EmailAddresses X500: <x500>
    2. Removing the cloud mailbox
      1. Remove the user from Office 365 and resync with AD sync.
        • remove-msoluser <user>
        • remove-msoluser <user> -removefromrecyclebin -force
      2. Clearing the previous mailbox information
        • Set-User <user> -PermanentlyClearPreviousMailboxInfo

Accidentally deleted a on-premise mailbox?

  1. Identify where the disconnected or soft deleted mailbox is. 
    • $dbs = Get-MailboxDatabase $dbs | foreach {Get-MailboxStatistics -Database $_.DistinguishedName} | where {$_.DisconnectReason -eq “Disabled”} | Format-Table DisplayName,Database,DisconnectDate
  2. Reconnect the mailbox
    1. Connect-Mailbox -Identity “<identity>” -Database <database> -User “<user>” -Alias <alias>

Accidentally deleted the on-premise user, but need to restore the data to cloud mailbox?

  1. Create a new temporary mailbox on-premise to restore the data to.
  2. Identify where the disconnected or soft deleted mailbox is. 
    • $dbs = Get-MailboxDatabase $dbs | foreach {Get-MailboxStatistics -Database $_.DistinguishedName} | where {$_.DisconnectReason -eq “Disabled”} | Format-Table DisplayName,Database,DisconnectDate,*guid*
  3. Restore the primary and archive data to the temporary mailbox
    • New-MailboxRestoreRequest -SourceStoreMailbox <mailbox guid> -SourceDatabase <database> -TargetMailbox <mailbox> -AllowLegacyDNMismatch
    • New-MailboxRestoreRequest -SourceStoreMailbox<mailbox guid> -SourceDatabase <database> -TargetMailbox <mailbox> -TargetIsArchive
  4. Export the data to PST (requires rights) 
    • NewManagementRoleAssignmentRole “Mailbox Import Export”User Administrator
    • New-MailboxExportRequest -Mailbox <mailbox> -FilePath <path>
    • New-MailboxExportRequest -Mailbox <mailbox> -FilePath <path> -isarchive
      • Ensure the Exchange Trust Subsystem group has read/write permissions to path
  5. Check status:
    • GetMailboxExportRequest | where {$_.status eq “Completed”}
  6. Remove job:
    • Get-MailboxRestoreRequest -Status Completed | Remove-MailboxRestoreRequest
    • Get-MailboxRestoreRequest -Status Failed | Remove-MailboxRestoreRequest
  7. Import to mailbox:
    • In Outlook with Exchange Online Mailbox, you can import directly – ensure you do not copy duplicates.
Categories: Exchange, Office365, Powershell Tags:
  1. No comments yet.
  1. No trackbacks yet.