Removing Orphaned Mailbox Searches

Removing Orphaned Mailbox Searches

  •  
  •  
  •  
  •  
  •  
  •  

An issue came up today for one of my customers–how to remove orphaned mailbox searches in Exchange Online.  Apparently, they have about 300 mailboxes in this state.  Oops.

So, in order to do this, you need to go through a handful of steps:

  1. Identify all of the Mailbox Searches.  This is pretty easy.
    $Searches = Get-MailboxSearch -ResultSize Unlimited
  2. Identify all of the InPlaceHolds on a mailbox.
    [System.Collections.ArrayList]$InPlaceHolds = (Get-Mailbox <identity>).InPlaceHolds
  3. Find the InPlaceHolds on the mailbox that don’t exist in the list of searches.
    $PotentiallyOrphaned = @()
    Foreach ($Search in $searches) 
    { 
         If ($InPlaceHolds -match $Search.InPlaceHoldIdentity) 
              { 
              $PotentiallyOrphaned += $Search.InPlaceHoldIdentity
              }
    }
  4. Remove the Orphaned Holds.
    Foreach ($Orphan in $PotentiallyOrphaned)
    { 
         Set-Mailbox -Identity <identity> -RemoveOrphanedHolds $Orphan 
    }

If you attempt to remove a mailbox hold that is not orphaned, you should receive a message telling you so.

Published by Aaron Guilmette

Helping companies conquer inferior technology since 1997. I spend my time developing and implementing technology solutions so people can spend less time with technology. Specialties: Active Directory and Exchange consulting and deployment, Virtualization, Disaster Recovery, Office 365, datacenter migration/consolidation, cheese.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.