# 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.