Commands › Exchange Online
Set-RetentionComplianceRule
For more information, see Security & Compliance PowerShell. Use the Set-RetentionComplianceRule cmdlet to modify existing retention rules in the Microsoft Purview compliance portal.
Quick start script
# Set-RetentionComplianceRule — 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-RetentionComplianceRule
$before | Format-List
# 3. Make the change (dry run first)
Set-RetentionComplianceRule -Identity <ComplianceRuleIdParameter> -WhatIf
Set-RetentionComplianceRule -Identity <ComplianceRuleIdParameter>
# 4. Verify and diff
$after = Get-RetentionComplianceRule
Compare-Object ($before | Out-String) ($after | Out-String)
Syntax
Set-RetentionComplianceRule [-Identity] <ComplianceRuleIdParameter>
[-ApplyComplianceTag <String>]
[-Comment <String>]
[-Confirm]
[-ContentContainsSensitiveInformation <PswsHashtable[]>]
[-ContentDateFrom <DateTime>]
[-ContentDateTo <DateTime>]
[-ContentMatchQuery <String>]
[-ExcludedItemClasses <MultiValuedProperty>]
[-ExpirationDateOption <String>]
[-IRMRiskyUserProfiles <String>]
[-PriorityCleanup]
[-RetentionComplianceAction <String>]
[-RetentionDuration <Unlimited>]
[-RetentionDurationDisplayHint <HoldDurationHint>]
[-WhatIf]
[<CommonParameters>]
Parameters (16)
Reference facts derived from Microsoft documentation, © Microsoft, licensed CC BY 4.0; restructured with original guidance by serv365.ai.