Commands › Exchange Online
New-HoldComplianceRule
For more information, see Security & Compliance PowerShell. Use the New-HoldComplianceRule cmdlet to create new preservation rules in the Microsoft Purview compliance portal. **Note**: The New-HoldComplianceRule cmdlet is replaced by the New-RetentionComplianceRule cmdlet. If you have scripts that use New-HoldComplianceRule, update them to use New-RetentionComplianceRule.
Quick start script
# New-HoldComplianceRule — quick start (serv365.ai)
# 1. Connect (app-only shown; interactive: omit the certificate parameters)
Connect-ExchangeOnline -CertificateThumbprint $thumb -AppId $appId -Organization $org
# 2. Capture the current state first — you cannot roll back what you never recorded
$before = Get-HoldComplianceRule
$before | Format-List
# 3. Make the change (dry run first)
New-HoldComplianceRule -Name <String> -Policy <PolicyIdParameter> -WhatIf
New-HoldComplianceRule -Name <String> -Policy <PolicyIdParameter>
# 4. Verify and diff
$after = Get-HoldComplianceRule
Compare-Object ($before | Out-String) ($after | Out-String)
Syntax
New-HoldComplianceRule [-Name] <String> -Policy <PolicyIdParameter>
[-Comment <String>]
[-Confirm]
[-ContentDateFrom <DateTime>]
[-ContentDateTo <DateTime>]
[-ContentMatchQuery <String>]
[-Disabled <Boolean>]
[-HoldContent <Unlimited>]
[-HoldDurationDisplayHint <HoldDurationHint>]
[-WhatIf]
[<CommonParameters>]
Parameters (11)
Reference facts derived from Microsoft documentation, © Microsoft, licensed CC BY 4.0; restructured with original guidance by serv365.ai.