Back to script library
Entra / Microsoft 365 · Exchange Online

Get holds on mailbox

Report holds in place for a mailbox and interpret their meaning. Requires Exchange Online and Security & Compliance PowerShell connections.

Connect & set up

Run these once per session. All scopes are read-only unless the script makes changes.

Connect-ExchangeOnline
Connect-IPPSSession

Run it

The main script. Copy it, or download the .ps1 and run it from your console.

$User = Read-Host "Enter User to check"
$Mbx = Get-Mailbox -Identity $User -ErrorAction SilentlyContinue
If ($Mbx -eq $Null)
{ Write-Host $User "is not a valid user"
Break
}
$OrgHolds = (Get-OrganizationConfig).InPlaceHolds
If ($OrgHolds.Count -gt 0) {
Write-Host "The following organization-wide mailbox holds are in force..."
ForEach ($Hold in $OrgHolds) {
$RetentionPolicy = (($Hold -Split ":")[0].Substring(3))
$HoldType = $Hold.Substring(0,3)
Switch ($HoldType)
{
"grp" {$Type = "Groups"}
"mbx" {$Type = "Mailbox"
Get-RetentionCompliancePolicy -Identity $RetentionPolicy | Select Name, Workload }
}}}
$MbxHolds = $Mbx.InPlaceHolds
If ($MbxHolds.Count -gt 0) {
Write-Host ""
Write-Host "The following specific holds are in place on the" $Mbx.DisplayName "mailbox..."
ForEach ($MHold in $MbxHolds) {
$RetentionPolicy = (($MHold -Split ":")[0].Substring(3))
$HoldType = $MHold.Substring(0,3)
$Text = $Null
Switch ($HoldType)
{
"grp" {$Type = "Groups"}
"skp" {$Type = "Skype IM Conversations"}
"uni" {$Type = "Unified Hold"
$CaseHold = $RetentionPolicy.SubString(1)
$Text = (Get-CaseHoldPolicy -Identity $CaseHold -ErrorAction SilentlyContinue).Name
If ($Text -ne $Null) {Write-Host "Hold Applied by:" $Text} }
"mbx" {$Type = "Mailbox"
$Text = (Get-RetentionCompliancePolicy -Identity $RetentionPolicy | Select Name, Workload)
Write-Host "Hold Applied by:" $Text.Name "on" $Text.Workload }
}
# There might be an old Exchange in place hold...
$int = $Mhold.substring(0,1)
If ([bool]($int -as [int]) -eq $True)
{ $Text = (Get-MailboxSearch -InPlaceHoldIdentity $MHold -ErrorAction SilentlyContinue).Name
Write-Host "Exchange In-Place Hold:" $Text }
}}
If ($Mbx.LitigationHoldEnabled -eq $True) {
Write-Host "Litigation hold is enabled on the mailbox" $Mbx.DisplayName }
Attribution