Office 365 DLP Policy Stuck Deleting Security & Compliance Center

Here in this Office 365 tutorial we will discuss how to resolve DLP Policy Stuck Deleting issue in Security & Compliance Center in Office 365. We will see how we can delete DLP policy in Office 365 using PowerShell.

Recently when I check Office 365 security & compliance center, I saw there was a policy which was showing Status as Deleting but it is stuck.

Office 365 DLP Policy Stuck Deleting Security & Compliance Center
Office 365 DLP Policy Stuck Deleting Security & Compliance Center

In the background, the policy was running and it was deleting the documents from various SharePoint sites.

When I try to delete the DLP Policy from the Security & Compliance Center, it was not deleting and giving below error.

Request: /api/policy?policyType=Dlp&identity=a14a5b5c-8000-44af-9972-df2cd66cffaf
Status code: 500
Exception message: {“Message”:”We cannot remove policy \u0027DLPPolicy1\u0027 since it is already in pending deletion state.”,”DiagnosticContext”:”{Version:16.00.2887.002,Environment:SEAPROD,DeploymentId:baab341de8c64fbebbaf7c782ead5db5,InstanceId:WebRole_IN_1,SID:3f911acd-c0e0-493f-a44f-0ba07adc2810,CID:c79db8f7-e9de-4f1c-b9a2-92f068e00c6c}”,”Time”:”2019-02-24T17:41:38.1432154Z”,”ExceptionType”:”Microsoft.Exchange.PswsClient.PswsException”}
Diagnostic information: **{Version:16.00.2887.002,Environment:SEAPROD,DeploymentId:baab341de8c64fbebbaf7c782ead5db5,InstanceId:WebRole_IN_2,SID:3f911acd-c0e0-493f-a44f-0ba07adc2810,CID:d590b08c-1a14-42df-b3f4-5d97b7b19089}
Time: 2019-02-24T17:41:57.851Z

So I deleted the DLP policy using PowerShell.

Delete DLP Policy using PowerShell in Office 365

If you are new to PowerShell, you can read an article on Working with PowerShell in SharePoint Online/2016/2013.

Below is the PowerShell Script to delete DLP Policy from Office 365 Security & Compliance Center.

You can write the PowerShell script in Visual studio code or Windows PowerShell ISE.

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Get-DlpCompliancePolicy
Remove-DlpCompliancePolicy "DLPPolicy1" -ForceDeletion
Delete DLP Policy using PowerShell Office 365 Security & Compliance Center
Delete DLP Policy using PowerShell Office 365 Security & Compliance Center

Once you run the command, the DLP policy will be deleted from Office 365 Security & Compliance Center.

Delete DLP Policy using PowerShell Office 365
Delete DLP Policy using PowerShell Office 365

Similarly, if you want to retrieve all the DLP Policies from Office 365 Security & Compliance Center.

Get-DlpCompliancePolicy

You may like following Office 365 tutorials:

Hope this SharePoint tutorial helps to resolve Office 365 DLP Policy Stuck Deleting Security & Compliance Center issue.

We saw how we can delete DLP policy using PowerShell in Office 365 Security & Compliance Center.

>