Commands › Exchange Online

Set-RetentionComplianceRule

Exchange Online ExchangeOnlineManagement Set-*

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)

ParameterTypeRequiredWhat it controls
-Identity ComplianceRuleIdParameter yes The Identity parameter specifies the retention rule that you want to modify. You can use any value that uniquely identifies the rule. For example:
-ApplyComplianceTag String The ApplyComplianceTag parameter specifies the label that's applied to email messages or documents by the rule (which affects how long the content is retained). A valid value for this parameter is the name of an...
-Comment String The Comment parameter specifies an optional comment. If you specify a value that contains spaces, enclose the value in quotation marks ("), for example: "This is an admin note".
-Confirm SwitchParameter The Confirm switch specifies whether to show or hide the confirmation prompt. How this switch affects the cmdlet depends on whether the cmdlet requires confirmation before proceeding.
-ContentContainsSensitiveInformation PswsHashtable[] The ContentContainsSensitiveInformation parameter specifies a condition for the rule that's based on a sensitive information type match in content. The rule is applied to content that contains the specified sensitive...
-ContentDateFrom DateTime The ContentDateFrom parameter specifies the start date of the date range for content to include.
-ContentDateTo DateTime The ContentDateTo parameter specifies the end date of the date range for content to include.
-ContentMatchQuery String The ContentMatchQuery parameter specifies a content search filter.
-ExcludedItemClasses MultiValuedProperty The ExcludedItemClasses parameter specifies the types of messages to exclude from the rule. You can use this parameter only to exclude items from a hold policy, which excludes the specified item class from being...
-ExpirationDateOption String The ExpirationDateOption parameter specifies whether the expiration date is calculated from the content creation date or last modification date. Valid values are:
-IRMRiskyUserProfiles String {{ Fill IRMRiskyUserProfiles Description }}
-PriorityCleanup SwitchParameter The PriorityCleanup switch specifies whether to update the rule associated with a Priority cleanup policy. You don't need to specify a value with this switch.
-RetentionComplianceAction String The RetentionComplianceAction parameter specifies the retention action for the rule. Valid values are:
-RetentionDuration Unlimited The RetentionDuration parameter specifies the hold duration for the retention rule. Valid values are:
-RetentionDurationDisplayHint HoldDurationHint The RetentionDurationDisplayHint parameter specifies the units that are used to display the retention duration in the Microsoft Purview compliance portal. Valid values are Days, Months or Years.
-WhatIf SwitchParameter The WhatIf switch doesn't work in Security & Compliance PowerShell.

Reference facts derived from Microsoft documentation, © Microsoft, licensed CC BY 4.0; restructured with original guidance by serv365.ai.