Commands › Exchange Online

Set-AutoSensitivityLabelPolicy

Exchange Online ExchangeOnlineManagement Set-*

For more information, see Security & Compliance PowerShell. Use the Set-AutoSensitivityLabelPolicy cmdlet to modify auto-labeling policies in your organization.

Quick start script

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

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

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

Syntax — 3 parameter sets

Identity

Set-AutoSensitivityLabelPolicy [-Identity] <PolicyIdParameter>
 [-AddExchangeLocation <MultiValuedProperty>]
 [-AddOneDriveLocation <MultiValuedProperty>]
 [-AddOneDriveLocationException <MultiValuedProperty>]
 [-AddSharePointLocation <MultiValuedProperty>]
 [-AddSharePointLocationException <MultiValuedProperty>]
 [-ApplySensitivityLabel <String>]
 [-ApplySensitivityLabelOverwriteWorkloads <Workload>]
 [-AutoEnableAfter <TimeSpan>]
 [-Comment <String>]
 [-Confirm]
 [-Enabled <Boolean>]
 [-ExceptIfOneDriveSharedBy <RecipientIdParameter[]>]
 [-ExceptIfOneDriveSharedByMemberOf <RecipientIdParameter[]>]
 [-ExchangeAdaptiveScopes <MultiValuedProperty>]
 [-ExchangeAdaptiveScopesException <MultiValuedProperty>]
 [-ExchangeSender <SmtpAddress[]>]
 [-ExchangeSenderException <SmtpAddress[]>]
 [-ExchangeSenderMemberOf <SmtpAddress[]>]
 [-ExchangeSenderMemberOfException <SmtpAddress[]>]
 [-ExternalMailRightsManagementOwner <SmtpAddress>]
 [-Force]
 [-Locations <String>]
 [-Mode <PolicyMode>]
 [-OneDriveAdaptiveScopes <MultiValuedProperty>]
 [-OneDriveAdaptiveScopesException <MultiValuedProperty>]
 [-OneDriveSharedBy <RecipientIdParameter[]>]
 [-OneDriveSharedByMemberOf <RecipientIdParameter[]>]
 [-OverwriteLabel <Boolean>]
 [-PolicyRBACScopes <MultiValuedProperty>]
 [-PolicyTemplateInfo <PswsHashtable>]
 [-Priority <System.Int32>]
 [-RemoveExchangeLocation <MultiValuedProperty>]
 [-RemoveOneDriveLocation <MultiValuedProperty>]
 [-RemoveOneDriveLocationException <MultiValuedProperty>]
 [-RemoveSharePointLocation <MultiValuedProperty>]
 [-RemoveSharePointLocationException <MultiValuedProperty>]
 [-SharePointAdaptiveScopes <MultiValuedProperty>]
 [-SharePointAdaptiveScopesException <MultiValuedProperty>]
 [-SpoAipIntegrationEnabled <Boolean>]
 [-StartSimulation <Boolean>]
 [-WhatIf]
 [<CommonParameters>]

TeamLocation

Set-AutoSensitivityLabelPolicy [-Identity] <PolicyIdParameter>
 [-Comment <String>]
 [-Confirm]
 [-Enabled <Boolean>]
 [-Force]
 [-Mode <PolicyMode>]
 [-WhatIf]
 [<CommonParameters>]

RetryDistributionParameterSet

Set-AutoSensitivityLabelPolicy [-Identity] <PolicyIdParameter>
 [-Confirm]
 [-Mode <PolicyMode>]
 [-RetryDistribution]
 [-WhatIf]
 [<CommonParameters>]

Parameters (43)

ParameterTypeRequiredWhat it controls
-Identity PolicyIdParameter yes The Identity parameter specifies the auto-labeling policy that you want to modify. You can use any value that uniquely identifies the policy. For example:
-AddExchangeLocation MultiValuedProperty The AddExchangeLocation parameter adds email messages to the policy if they aren't already included. The valid value for this parameter is All.
-AddOneDriveLocation MultiValuedProperty The AddOneDriveLocation parameter specifies the OneDrive sites to add to the list of included sites when you aren't using the value All for the OneDriveLocation parameter. You identify the site by its URL value.
-AddOneDriveLocationException MultiValuedProperty The AddOneDriveLocationException parameter specifies the OneDrive sites to add to the list of excluded sites when you use the value All for the OneDriveLocation parameter. You identify the site by its URL value.
-AddSharePointLocation MultiValuedProperty The AddSharePointLocation parameter specifies the SharePoint sites to add to the list of included sites when you aren't using the value All for the SharePointLocation parameter. You identify the site by its URL value.
-AddSharePointLocationException MultiValuedProperty The AddSharePointLocationException parameter specifies the SharePoint sites to add to the list of excluded sites when you use the value All for the SharePointLocation parameter. You identify the site by its URL value.
-ApplySensitivityLabel String The ApplySensitivityLabel parameter selects the label to use for the policy. This value overrides the previous label on the policy.
-ApplySensitivityLabelOverwriteWorkloads Workload {{ Fill ApplySensitivityLabelOverwriteWorkloads Description }}
-AutoEnableAfter TimeSpan The AutoEnableAfter parameter allows you to automatically turn on the policy after a set time period in simulation with no modifications to the policy. You need to explicitly set this parameter after each policy edit...
-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.
-Enabled Boolean The Enabled parameter enables or disables the policy. Valid values are:
-ExceptIfOneDriveSharedBy RecipientIdParameter[] The ExceptIfOneDriveSharedBy parameter specifies the users to exclude from the policy (the sites of the OneDrive user accounts are included in the policy). You identify the users by UPN (`laura@contoso.onmicrosoft.com`).
-ExceptIfOneDriveSharedByMemberOf RecipientIdParameter[] {{ Fill ExceptIfOneDriveSharedByMemberOf Description }}
-ExchangeAdaptiveScopes MultiValuedProperty {{ Fill ExchangeAdaptiveScopes Description }}
-ExchangeAdaptiveScopesException MultiValuedProperty {{ Fill ExchangeAdaptiveScopesException Description }}
-ExchangeSender SmtpAddress[] The ExchangeSender parameter specifies the users whose email is included in the policy. You specify the users by email address. You can specify internal or external email addresses.
-ExchangeSenderException SmtpAddress[] The ExchangeSenderException parameter specifies the internal users whose email is excluded from the policy. You identify the users by email address.
-ExchangeSenderMemberOf SmtpAddress[] The ExchangeSenderMemberOf parameter specifies the distribution groups or mail-enabled security groups to include in the policy (email of the group members is included in the policy). You identify the groups by email address.
-ExchangeSenderMemberOfException SmtpAddress[] The ExchangeSenderMemberOfException parameter specifies the distribution groups or mail-enabled security groups to exclude from the policy (email of the group members is excluded from the policy). You identify the...
-ExternalMailRightsManagementOwner SmtpAddress The ExternalMailRightsManagementOwner parameter specifies the email address of a user mailbox that's used to encrypt incoming email messages from external senders using RMS.
-Force SwitchParameter The Force switch hides warning or confirmation messages. You don't need to specify a value with this switch.
-Locations String {{ Fill Locations Description }}
-Mode PolicyMode The Mode parameter specifies the action and notification level of the auto-labeling policy. Valid values are:
-OneDriveAdaptiveScopes MultiValuedProperty {{ Fill OneDriveAdaptiveScopes Description }}
-OneDriveAdaptiveScopesException MultiValuedProperty {{ Fill OneDriveAdaptiveScopesException Description }}
-OneDriveSharedBy RecipientIdParameter[] The OneDriveSharedBy parameter specifies the users to include in the policy (the sites of the OneDrive user accounts are included in the policy). You identify the users by UPN (`laura@contoso.onmicrosoft.com`).
-OneDriveSharedByMemberOf RecipientIdParameter[] {{ Fill OneDriveSharedByMemberOf Description }}
-OverwriteLabel Boolean The OverwriteLabel parameter specifies whether to overwrite a manual label. Valid values are:
-PolicyRBACScopes MultiValuedProperty The PolicyRBACScopes parameter specifies the administrative units to assign to the policy. A valid value is the Microsoft Entra ObjectID (GUID value) of the administrative unit. You can specify multiple values...
-PolicyTemplateInfo PswsHashtable This parameter is reserved for internal Microsoft use.
-Priority Int32 The Priority parameter specifies a priority value for the policy that determines the order of policy processing. A lower integer value indicates a higher priority, the value 0 is the highest priority, and policies...
-RemoveExchangeLocation MultiValuedProperty The RemoveExchangeLocation parameter removes email messages from the policy if they're already included. The valid value for this parameter is All.
-RemoveOneDriveLocation MultiValuedProperty The RemoveOneDriveLocation parameter specifies the OneDrive sites to remove from the list of included sites when you aren't using the value All for the OneDriveLocation parameter. You identify the site by its URL value.
-RemoveOneDriveLocationException MultiValuedProperty This RemoveOneDriveLocationException parameter specifies the OneDrive sites to remove from the list of excluded sites when you use the value All for the OneDriveLocation parameter. You identify the site by its URL value.
-RemoveSharePointLocation MultiValuedProperty The RemoveSharePointLocation parameter specifies the SharePoint sites to remove from the list of included sites when you aren't using the value All for the SharePointLocation parameter. You identify the site by its URL value.
-RemoveSharePointLocationException MultiValuedProperty The RemoveSharePointLocationException parameter specifies the SharePoint sites to remove from the list of excluded sites when you use the value All for the SharePointLocation parameter. You identify the site by its URL value.
-RetryDistribution SwitchParameter yes The RetryDistribution switch redistributes the policy to all OneDrive and SharePoint locations. You don't need to specify a value with this switch.
-SharePointAdaptiveScopes MultiValuedProperty {{ Fill SharePointAdaptiveScopes Description }}
-SharePointAdaptiveScopesException MultiValuedProperty {{ Fill SharePointAdaptiveScopesException Description }}
-SpoAipIntegrationEnabled Boolean The SpoAipIntegrationEnabled parameter enables or disables built-in labeling for supported Office files in SharePoint and OneDrive. Valid values are:
-StartSimulation Boolean Use the StartSimulation parameter to restart the simulation for updated results. 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.