Commands › Exchange Online

Set-AppRetentionCompliancePolicy

Exchange Online ExchangeOnlineManagement Set-*

For more information, see Security & Compliance PowerShell. Use the Set-AppRetentionCompliancePolicy to modify app retention compliance policies.

Quick start script

# Set-AppRetentionCompliancePolicy — 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-AppRetentionCompliancePolicy
$before | Format-List

# 3. Make the change (dry run first)
Set-AppRetentionCompliancePolicy -Identity <PolicyIdParameter> -RetryDistribution <SwitchParameter> -WhatIf
Set-AppRetentionCompliancePolicy -Identity <PolicyIdParameter> -RetryDistribution <SwitchParameter>

# 4. Verify and diff
$after = Get-AppRetentionCompliancePolicy
Compare-Object ($before | Out-String) ($after | Out-String)

Syntax — 7 parameter sets

Identity (Default)

Set-AppRetentionCompliancePolicy [-Identity] <PolicyIdParameter>
 [-AddExchangeLocation <MultiValuedProperty>]
 [-AddExchangeLocationException <MultiValuedProperty>]
 [-AddModernGroupLocation <MultiValuedProperty>]
 [-AddModernGroupLocationException <MultiValuedProperty>]
 [-Applications <String[]>]
 [-Comment <String>]
 [-Confirm]
 [-DeletedResources <String>]
 [-Enabled <Boolean>]
 [-Force]
 [-PolicyRBACScopes <MultiValuedProperty>]
 [-RemoveExchangeLocation <MultiValuedProperty>]
 [-RemoveExchangeLocationException <MultiValuedProperty>]
 [-RemoveModernGroupLocation <MultiValuedProperty>]
 [-RemoveModernGroupLocationException <MultiValuedProperty>]
 [-RestrictiveRetention <Boolean>]
 [-WhatIf]
 [<CommonParameters>]

AdaptiveScopeLocation

Set-AppRetentionCompliancePolicy [-Identity] <PolicyIdParameter>
 [-AddAdaptiveScopeLocation <MultiValuedProperty>]
 [-Applications <String[]>]
 [-Comment <String>]
 [-Confirm]
 [-DeletedResources <String>]
 [-Enabled <Boolean>]
 [-Force]
 [-RemoveAdaptiveScopeLocation <MultiValuedProperty>]
 [-WhatIf]
 [<CommonParameters>]

DisableRestrictiveRetentionParameterSet

Set-AppRetentionCompliancePolicy [-Identity] <PolicyIdParameter>
 [-Confirm]
 [-DeletedResources <String>]
 [-WhatIf]
 [<CommonParameters>]

InformationBarrierDefault

Set-AppRetentionCompliancePolicy [-Identity] <PolicyIdParameter>
 [-Confirm]
 [-DeletedResources <String>]
 [-Force]
 [-WhatIf]
 [<CommonParameters>]

3 more parameter sets — see the parameter table below.

Parameters (21)

ParameterTypeRequiredWhat it controls
-Identity PolicyIdParameter yes The Identity parameter specifies the app retention compliance policy that you want to modify. You can use any value that uniquely identifies the policy. For example:
-RetryDistribution SwitchParameter yes The RetryDistribution switch specifies whether to redistribute the policy to all locations. You don't need to specify a value with this switch.
-AddAdaptiveScopeLocation MultiValuedProperty The AddAdaptiveScopeLocation parameter specifies the adaptive scope location to add to the policy. You create adaptive scopes by using the New-AdaptiveScope cmdlet. You can use any value that uniquely identifies the...
-AddExchangeLocation MultiValuedProperty The AddExchangeLocation parameter specifies the mailboxes to add to the list of included mailboxes when you aren't using the value All for the ExchangeLocation parameter. Valid values are:
-AddExchangeLocationException MultiValuedProperty The AddExchangeLocationException parameter specifies the mailboxes to add to the list of excluded mailboxes when you're using the value All for the ExchangeLocation parameter. Valid values are:
-AddModernGroupLocation MultiValuedProperty The AddModernGroupLocation parameter specifies the Microsoft 365 Groups to add to the list of included Microsoft 365 Groups when you aren't using the value All for the ModernGroupLocation parameter.
-AddModernGroupLocationException MultiValuedProperty The AddModernGroupLocationException parameter specifies the Microsoft 365 Groups to add to the list of excluded Microsoft 365 Groups when you're using the value All for the ModernGroupLocation parameter.
-Applications String[] The Applications parameter specifies the applications to include in the policy.
-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.
-DeletedResources String The DeletedResources parameter specifies the deleted mailbox or mail user to add as an exclusion to the respective location list. Use this parameter with the AddTeamsChatLocationException parameter for deleted...
-Enabled Boolean The Enabled parameter enables or disables the policy. Valid values are:
-Force SwitchParameter The Force switch hides warning or confirmation messages. You don't need to specify a value with this switch.
-PolicyRBACScopes MultiValuedProperty **Note**: Admin units aren't currently supported, so this parameter isn't functional. The information presented here is for informational purposes when support for admin units is released.
-RemoveAdaptiveScopeLocation MultiValuedProperty The RemoveAdaptiveScopeLocation parameter specifies the adaptive scope location to remove from the policy. You create adaptive scopes by using the New-AdaptiveScope cmdlet. You can use any value that uniquely...
-RemoveExchangeLocation MultiValuedProperty The RemoveExchangeLocation parameter specifies the mailboxes to remove from the list of included mailboxes when you aren't using the value All for the ExchangeLocation parameter. Valid values are:
-RemoveExchangeLocationException MultiValuedProperty The RemoveExchangeLocationException parameter specifies the mailboxes to remove from the list of excluded mailboxes when you use the value All for the ExchangeLocation parameter. Valid values are:
-RemoveModernGroupLocation MultiValuedProperty The RemoveModernGroupLocation parameter specifies the Microsoft 365 Groups to remove from the list of included groups when you aren't using the value All for the ModernGroupLocation parameter.
-RemoveModernGroupLocationException MultiValuedProperty The RemoveModernGroupLocationException parameter specifies the Microsoft 365 Groups to remove from the list of excluded groups when you're using the value All for the ModernGroupLocation parameter.
-RestrictiveRetention Boolean The RestrictiveRetention parameter specifies whether Preservation Lock is enabled for the policy. Valid values are:
-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.