Troubleshooting Mailboxes in Hybrid Exchange Deployments
In a hybrid Exchange deployment, it is possible for users to have mailboxes both on-premises and on Office 365. This can occur when an user is assigned an Exchange Online license before their mailbox has been migrated to Office 365. In such cases, Outlook may still be configured to use the on-premises mailbox, leading to some unusual issues. For instance, sent items will remain in the on-premises mailbox while new items will arrive in Office 365.
To troubleshoot such issues, we can use PowerShell commands to verify if a user has a mailbox on Office 365. The following command returns all objects in Office 365:
“`
Get-Mailbox -Filter {RecipientType -eq “UserMailbox”}
“`
Once you have identified the user with a mailbox on Office 365, you need to remove the object from Office 365. This can be done by moving the user to an OU that is not synced with AADConnect. To do this, use the following command:
“`
Move-Object -Identity -TargetOU “”
“`
After moving the user to a non-synced OU, you can run another AD Sync or wait until the next time the scheduled task runs. This sync will remove the user from Azure AD and flag the mailbox as “SoftDeleted”. The mailbox will then be placed in the recycle bin, where it will stay for 30 days before being automatically deleted.
To delete the mailbox permanently, use the following PowerShell command:
“`
Remove-Mailbox -Identity -PermanentlyDelete
“`
Please note that due to the distributed nature of Office 365, it may take up to 15 minutes for the changes to replicate. Therefore, it is important to wait for the changes to propagate before proceeding with any further actions.
Finally, to ensure that the user is recreated in Azure AD and appears in the Office 365 admin center, move the user back to an OU that is synced. The next time the scheduled task runs, the user will be recreated in Azure AD and will appear in the Office 365 admin center.
In conclusion, troubleshooting mailboxes in hybrid Exchange deployments can be a bit challenging, but by using PowerShell commands, you can easily identify and remove any mailboxes that are not supposed to be on Office 365. Remember to wait for the changes to replicate before proceeding with any further actions, and always verify that the user has been successfully removed from Office 365 before moving on to the next step.