Commands › Exchange Online

Set-DlpCompliancePolicy

Exchange Online ExchangeOnlineManagement Set-*

For more information, see Security & Compliance PowerShell. Use the Set-DlpCompliancePolicy cmdlet to modify data loss prevention (DLP) policies in the Microsoft Purview compliance portal.

Quick start script

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

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

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

Syntax — 2 parameter sets

Identity

Set-DlpCompliancePolicy [-Identity] <PolicyIdParameter>
 [-AddEndpointDlpLocation <MultiValuedProperty>]
 [-AddEndpointDlpLocationException <MultiValuedProperty>]
 [-AddExchangeLocation <MultiValuedProperty>]
 [-AddOneDriveLocation <MultiValuedProperty>]
 [-AddOneDriveLocationException <MultiValuedProperty>]
 [-AddOnPremisesScannerDlpLocation <MultiValuedProperty>]
 [-AddOnPremisesScannerDlpLocationException <MultiValuedProperty>]
 [-AddPowerBIDlpLocation <MultiValuedProperty>]
 [-AddPowerBIDlpLocationException <MultiValuedProperty>]
 [-AddSharePointLocation <MultiValuedProperty>]
 [-AddSharePointLocationException <MultiValuedProperty>]
 [-AddTeamsLocation <MultiValuedProperty>]
 [-AddTeamsLocationException <MultiValuedProperty>]
 [-AddThirdPartyAppDlpLocation <MultiValuedProperty>]
 [-AddThirdPartyAppDlpLocationException <MultiValuedProperty>]
 [-Comment <String>]
 [-Confirm]
 [-DisplayName <String>]
 [-EndpointDlpAdaptiveScopes <MultiValuedProperty>]
 [-EndpointDlpAdaptiveScopesException <MultiValuedProperty>]
 [-EnforcementPlanes <MultiValuedProperty>]
 [-ExceptIfOneDriveSharedBy <RecipientIdParameter[]>]
 [-ExceptIfOneDriveSharedByMemberOf <RecipientIdParameter[]>]
 [-ExchangeAdaptiveScopes <MultiValuedProperty>]
 [-ExchangeAdaptiveScopesException <MultiValuedProperty>]
 [-ExchangeSenderMemberOf <RecipientIdParameter[]>]
 [-ExchangeSenderMemberOfException <RecipientIdParameter[]>]
 [-Force]
 [-IsFromSmartInsights <System.Boolean>]
 [-Locations <String>]
 [-Mode <PolicyMode>]
 [-OneDriveAdaptiveScopes <MultiValuedProperty>]
 [-OneDriveAdaptiveScopesException <MultiValuedProperty>]
 [-OneDriveSharedBy <RecipientIdParameter[]>]
 [-OneDriveSharedByMemberOf <RecipientIdParameter[]>]
 [-PolicyRBACScopes <MultiValuedProperty>]
 [-PolicyTemplateInfo <PswsHashtable>]
 [-Priority <Int32>]
 [-RemoveEndpointDlpLocation <MultiValuedProperty>]
 [-RemoveEndpointDlpLocationException <MultiValuedProperty>]
 [-RemoveExchangeLocation <MultiValuedProperty>]
 [-RemoveOneDriveLocation <MultiValuedProperty>]
 [-RemoveOneDriveLocationException <MultiValuedProperty>]
 [-RemoveOnPremisesScannerDlpLocation <MultiValuedProperty>]
 [-RemoveOnPremisesScannerDlpLocationException <MultiValuedProperty>]
 [-RemovePowerBIDlpLocation <MultiValuedProperty>]
 [-RemovePowerBIDlpLocationException <MultiValuedProperty>]
 [-RemoveSharePointLocation <MultiValuedProperty>]
 [-RemoveSharePointLocationException <MultiValuedProperty>]
 [-RemoveTeamsLocation <MultiValuedProperty>]
 [-RemoveTeamsLocationException <MultiValuedProperty>]
 [-RemoveThirdPartyAppDlpLocation <MultiValuedProperty>]
 [-RemoveThirdPartyAppDlpLocationException <MultiValuedProperty>]
 [-StartSimulation <Boolean>]
 [-TeamsLocation <MultiValuedProperty>]
 [-TeamsLocationException <MultiValuedProperty>]
 [-WhatIf]
 [<CommonParameters>]

RetryDistribution

Set-DlpCompliancePolicy [-Identity] <PolicyIdParameter> [-RetryDistribution]
 [-Confirm]
 [-WhatIf]
 [<CommonParameters>]

Parameters (59)

ParameterTypeRequiredWhat it controls
-Identity PolicyIdParameter yes The Identity parameter specifies the DLP policy that you want to modify. You can use any value that uniquely identifies the policy. For example:
-RetryDistribution SwitchParameter yes The RetryDistribution switch redistributes the policy to all Exchange, OneDrive, and SharePoint locations. You don't need to specify a value with this switch.
-AddEndpointDlpLocation MultiValuedProperty **Note**: This parameter requires membership in the Compliance Administrator or Compliance Data Administrator roles in Microsoft Entra ID.
-AddEndpointDlpLocationException MultiValuedProperty **Note**: This parameter requires membership in the Compliance Administrator or Compliance Data Administrator roles in Microsoft Entra ID.
-AddExchangeLocation MultiValuedProperty The AddExchangeLocation parameter adds email messages to the DLP policy if they aren't already included. The valid value for this parameter is All.
-AddOneDriveLocation MultiValuedProperty The AddOneDriveLocation parameter adds OneDrive sites to the DLP policy if they aren't already included. The valid value for this parameter is All.
-AddOneDriveLocationException MultiValuedProperty Don't use this parameter. See the AddOneDriveLocation parameter for an explanation.
-AddOnPremisesScannerDlpLocation MultiValuedProperty The AddOnPremisesScannerDlpLocation parameter specifies the on-premises file shares and SharePoint document libraries and folders to add to the list of included repositories if you used the value All for the...
-AddOnPremisesScannerDlpLocationException MultiValuedProperty The AddOnPremisesScannerDlpLocationExclusion parameter specifies the on-premises file shares and SharePoint document libraries and folders to add to the list of excluded repositories if you used the value All for the...
-AddPowerBIDlpLocation MultiValuedProperty The AddPowerBIDlpLocation parameter specifies the Power BI workspace IDs to add to the list of included workspaces if you used the value All for the PowerBIDlpLocation parameter. Only workspaces hosted in Premium...
-AddPowerBIDlpLocationException MultiValuedProperty The AddPowerBIDlpLocationException parameter specifies the Power BI workspace IDs to add to the list of excluded workspaces if you used the value All for the PowerBIDlpLocation parameter. Only workspaces hosted in...
-AddSharePointLocation MultiValuedProperty The AddSharePointLocation parameter specifies the SharePoint sites to add to the list of included sites if you used 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 if you used the value All for the SharePointLocation parameter. You identify the site by its URL value.
-AddTeamsLocation MultiValuedProperty The AddTeamsLocation parameter specifies the accounts, distribution groups, or mail-enabled security groups to add to the list of included Teams chat and channel messages if you used the value All for the...
-AddTeamsLocationException MultiValuedProperty The AddTeamsLocationException parameter specifies the accounts, distribution groups, or mail-enabled security groups to add to the list of excluded Teams chat and channel messages if you used the value All for the...
-AddThirdPartyAppDlpLocation MultiValuedProperty **Note**: This parameter requires membership in the Compliance Administrator or Compliance Data Administrator roles in Microsoft Entra ID.
-AddThirdPartyAppDlpLocationException MultiValuedProperty **Note**: This parameter requires membership in the Compliance Administrator or Compliance Data Administrator roles in Microsoft Entra ID.
-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.
-DisplayName String {{ Fill DisplayName Description }}
-EndpointDlpAdaptiveScopes MultiValuedProperty {{ Fill EndpointDlpAdaptiveScopes Description }}
-EndpointDlpAdaptiveScopesException MultiValuedProperty {{ Fill EndpointDlpAdaptiveScopesException Description }}
-EnforcementPlanes MultiValuedProperty The EnforcementPlanes parameter defines the layer where policy actions are run. This parameter uses the following syntax:
-ExceptIfOneDriveSharedBy RecipientIdParameter[] The ExceptIfOneDriveSharedBy parameter specifies the users to exclude from the DLP 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[] The ExceptIfOneDriveSharedByMemberOf parameter specifies the distribution groups or mail-enabled security groups to exclude from the DLP policy (the OneDrive sites of group members are excluded from the policy). You...
-ExchangeAdaptiveScopes MultiValuedProperty {{ Fill ExchangeAdaptiveScopes Description }}
-ExchangeAdaptiveScopesException MultiValuedProperty {{ Fill ExchangeAdaptiveScopesException Description }}
-ExchangeSenderMemberOf RecipientIdParameter[] The ExchangeSenderMemberOf parameter specifies the distribution groups or 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 RecipientIdParameter[] The ExchangeSenderMemberOfException parameter specifies the distribution groups or security groups to exclude from the policy (email of the group members is excluded from the policy). You identify the groups by email address.
-Force SwitchParameter The Force switch hides warning or confirmation messages. You don't need to specify a value with this switch.
-IsFromSmartInsights Boolean {{ Fill IsFromSmartInsights Description }}
-Locations String The Locations parameter specifies to whom, what, and where the DLP policy applies. This parameter uses the following properties:
-Mode PolicyMode The Mode parameter specifies the action and notification level of the DLP 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 DLP 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[] The OneDriveSharedByMemberOf parameter specifies the distribution groups or mail-enabled security groups to include in the DLP policy (the OneDrive sites of group members are included in the policy). You identify the...
-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 The PolicyTemplateInfo specifies the built-in or custom DLP policy templates to use in the DLP policy.
-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...
-RemoveEndpointDlpLocation MultiValuedProperty **Note**: This parameter requires membership in the Compliance Administrator or Compliance Data Administrator roles in Microsoft Entra ID.
-RemoveEndpointDlpLocationException MultiValuedProperty **Note**: This parameter requires membership in the Compliance Administrator or Compliance Data Administrator roles in Microsoft Entra ID.
-RemoveExchangeLocation MultiValuedProperty The RemoveExchangeLocation parameter removes email messages from the DLP policy if they're already included. The valid value for this parameter is All.
-RemoveOneDriveLocation MultiValuedProperty The RemoveOneDriveLocation parameter removes OneDrive sites from the DLP policy if they're already included. The valid value for this parameter is All.
-RemoveOneDriveLocationException MultiValuedProperty Don't use this parameter. See the RemoveOneDriveLocation parameter for an explanation.
-RemoveOnPremisesScannerDlpLocation MultiValuedProperty The RemoveOnPremisesScannerDlpLocation parameter specifies the on-premises file shares and SharePoint document libraries and folders to remove from the list of included repositories if you used the value All for the...
-RemoveOnPremisesScannerDlpLocationException MultiValuedProperty The RemoveOnPremisesScannerDlpLocationException parameter specifies the on-premises file shares and SharePoint document libraries and folders to remove from the list of excluded repositories if you used the value All...
-RemovePowerBIDlpLocation MultiValuedProperty The RemovePowerBIDlpLocation parameter specifies the Power BI workspace IDs to remove from the list of included workspaces if you used the value All for the PowerBIDlpLocation parameter. Only workspaces hosted in...
-RemovePowerBIDlpLocationException MultiValuedProperty The RemovePowerBIDlpLocationException parameter specifies the Power BI workspace IDs to remove the list of excluded workspaces if you used the value All for the PowerBIDlpLocation parameter. Only workspaces hosted in...
-RemoveSharePointLocation MultiValuedProperty The RemoveSharePointLocation parameter specifies the SharePoint sites to remove from the list of included sites if you used the value All for the SharePointLocation parameter. You specify the site by its URL value.
-RemoveSharePointLocationException MultiValuedProperty The RemoveSharePointLocationException parameter specifies the SharePoint sites to remove from the list of excluded sites if you used the value All for the SharePointLocation parameter. You specify the site by its URL value.
-RemoveTeamsLocation MultiValuedProperty The RemoveTeamsLocation parameter specifies the accounts, distribution groups, or mail-enabled security groups to remove from the list of included Teams chat and channel messages if you used the value All for the...
-RemoveTeamsLocationException MultiValuedProperty The RemoveTeamsLocationException parameter specifies the accounts, distribution groups, or mail-enabled security groups to remove from the list of excluded Teams chat and channel messages if you used the value All...
-RemoveThirdPartyAppDlpLocation MultiValuedProperty **Note**: This parameter requires membership in the Compliance Administrator or Compliance Data Administrator roles in Microsoft Entra ID.
-RemoveThirdPartyAppDlpLocationException MultiValuedProperty **Note**: This parameter requires membership in the Compliance Administrator or Compliance Data Administrator roles in Microsoft Entra ID.
-StartSimulation Boolean {{ Fill StartSimulation Description }}
-TeamsAdaptiveScopes MultiValuedProperty {{ Fill TeamsAdaptiveScopes Description }}
-TeamsAdaptiveScopesException MultiValuedProperty {{ Fill TeamsAdaptiveScopesException Description }}
-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.