Office 365: Detecting and preventing duplicate mailboxes between On-Premises and Exchange Online


In Office 365 when licenses are assigned to a user a mailbox should not be provisioned if the user has a mailbox on premises.  Our provisioning logic looks to see if there is a replicated Exchange GUID to make a determination on the type of object that should be provisioned.  The one exception of this is if the account has a previousRecipientDisplayTypeDetails of UserMailbox.  In all cases if this recipient type is a UserMailbox a mailbox will be provisioned.  This can lead to duplicate mailboxes between Office 365 and on premises Exchange.


I detail some of these situations in the following blog posts:


https://blogs.technet.microsoft.com/timmcmic/2017/09/10/office-365-users-have-both-a-cloud-and-on-premises-mailbox/

https://blogs.technet.microsoft.com/timmcmic/2018/04/09/office-365-licensing-mail-users-results-in-mailbox-objects/



To being identifying users that might have the probability of having a duplicate mailbox created we must first pull all mail users that have a populated Exchange GUID.  If a mail user has an Exchange GUID – it should match the on premise mailbox. 


$mailUsers=Get-MailUser -ResultSize unlimited | where {$_.exchangeGUID -notlike "*00000*"}

$mailUsers


Name                                     RecipientType

----                                     -------------

Journal Mailbox                          MailUser

TestCloud0                               MailUser

TestCloud1                               MailUser

TestCloud2                               MailUser

TestCloud3                               MailUser

TestCloud4                               MailUser


The second step is to trim the list down further to those mail users that have a previousRecipientDisplayTypeDetails of UserMailbox. 


$users=$mailUsers | % {get-user $_.alias | where {$_.PreviousRecipientTypeDetails -eq "UserMailbox"}}

$users


Name       RecipientType

----       -------------

TestCloud0 MailUser

TestCloud1 MailUser

TestCloud2 MailUser

TestCloud3 MailUser

TestCloud4 MailUser


The array of users created above should reflect all mail users where the Exchange GUID is populated and the previous recipient type details are UserMailbox.


We now support resetting the users previousRecipientTypeDetails through the set-user command.  IMPORTANT NOTE:  When resetting these values if there is any data in the cloud mailbox that you wish to have recovered DO NOT proceed with these instructions.  Continuing to follow these instructions will result in the inability to recover data.  Using a loop we are able to move through the array of users and clear the previous recipient type details. 


To reset the previousRecipientTypeDetails…


$users | % {Set-User -Identity $_.samAccountName -PermanentlyClearPreviousMailboxInfo -Confirm:$FALSE -Verbose}





VERBOSE: Delete all existing information about user "TestC505571820778136"?. This operation will clear existing values

from Previous home MDB and Previous Mailbox GUID of the user. After deletion, reconnecting to the previous mailbox that
  existed in the cloud will not be possible and any content it had will be unrecoverable PERMANENTLY. Do you want to

continue?

VERBOSE: Delete all existing information about user "Test56390-1214024844"?. This operation will clear existing values

from Previous home MDB and Previous Mailbox GUID of the user. After deletion, reconnecting to the previous mailbox that
  existed in the cloud will not be possible and any content it had will be unrecoverable PERMANENTLY. Do you want to

continue?

VERBOSE: Delete all existing information about user "TestCl56390595684140"?. This operation will clear existing values

from Previous home MDB and Previous Mailbox GUID of the user. After deletion, reconnecting to the previous mailbox that
  existed in the cloud will not be possible and any content it had will be unrecoverable PERMANENTLY. Do you want to

continue?

VERBOSE: Delete all existing information about user "TestCl50043487409662"?. This operation will clear existing values

from Previous home MDB and Previous Mailbox GUID of the user. After deletion, reconnecting to the previous mailbox that
  existed in the cloud will not be possible and any content it had will be unrecoverable PERMANENTLY. Do you want to

continue?

VERBOSE: Delete all existing information about user "Test58465-1005051264"?. This operation will clear existing values

from Previous home MDB and Previous Mailbox GUID of the user. After deletion, reconnecting to the previous mailbox that
  existed in the cloud will not be possible and any content it had will be unrecoverable PERMANENTLY. Do you want to

continue?


Using powershell to validate that our changes were successful by restarting the discover process outlined above.


$mailUsers=Get-MailUser -ResultSize unlimited | where {$_.exchangeGUID -notlike "*00000*"}

$users=$mailUsers | % {get-user $_.alias | where {$_.PreviousRecipientTypeDetails -eq "UserMailbox"}}

$users

$users.count

0


With the users array count being zero there are no mail users left with a previous recipient display type of user mailbox.  With this value cleared – should a license be assigned to the user a mailbox will not be generated in Exchange Online.


Comments (0)

Skip to main content