Hybrid Exchange duplicate Mailbox's issue

Copper Contributor

We've discovered an issue where newly created users who are given 365 mailbox's also get an inhouse mailbox so some mail is delivered to one and some to the other, either way they miss email.  This script can detect these miss configured mailbox's.

 

It has to be run in an Exchange Online Powershell which can be loaded from the Exchange Admin center under Hybrid and press the second Configure button.

 

The $MyUser variable contains your logon name.  In this script it's made up from the logon name and our domain but you'll need to modify it to suit you're environment.

 

--------------Script----------------

cls
"Loading In House Mailbox Details"
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
$UserInHouses = Get-User
"Loaded"
"Loading 365 Mailbox Details"
$MyUser = (get-childitem env:USERNAME).Value
$MyUser += '@OurDomain.com'
$Session = connect-EXOPSSession -UserPrincipalName $MyUser
$Users365 = get-user
Get-PSSession | Remove-PSSession
"Loaded"
"Processing"
""
"Duplicate User Mailbox's:-"
ForEach ($UserInHouse in $UserInHouses)
{
     ForEach ($User365 in $Users365)
     {
          if ($User365.Name -like $UserInHouse.Name)
          {
               if (($User365.RecipientType -like 'UserMailbox') -and ($UserInHouse.RecipientType -like 'UserMailbox'))
               {
                    $User365.name
               }
          }
     }
}
""

--------------Script----------------

 

To fix this problem remove the Exchange Online (Plan **) licence from their account and the online mailbox will be deleted.   If there's data in there it will be lost so you'll have to back it up first.

0 Replies