Good afternoon,

I hope to get some advice on how to tackle the following task:

I’ve automated the provisioning of SharePoint websites and the user can request a website using a PowerApps form. On the form, they can also select their desired security level for their website. Once they selected their desired level of security and clicked the request button, the flow runs and creates a SharePoint site using a PowerShell script.

What I would like to do now is to create data loss prevention policies (DLP) in Security & Compliance Center in advance and automatically add newly created SharePoint sites to the right DLP policy based on the user’s preferred security level chosen in the PowerApps form.

Is it even possible to automate this process with PowerShell? So far my research is pointing towards a "No".

New contributor
Mark is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Not sure if it meets your requirement but it is supported to create and modify a DLP policy using PowerShell.

Here is a PowerShell example that a DLP policy named GlobalPolicy for the specified SharePoint Online and OneDrive for Business locations:

New-DlpCompliancePolicy -Name "GlobalPolicy" -Comment "Primary policy" -SharePointLocation "https://my.url","https://my.url2" -OneDriveLocation "https://my.url3","https://my.url4" -Mode Enable

And this example adds the specified URLs to the SharePoint Online and OneDrive for Business locations for the DLP policy named Main PII without affecting the existing URL values:

Set-DlpCompliancePolicy -Identity "Main PII" -AddSharePointLocation "https://my.url1","https://my.url2" -AddOneDriveLocation "https://my.url3","https://my.url4"

The cmdlets are available only in Office 365 Security & Compliance Center PowerShell.


Create the DLP policy by using PowerShell.



Your Answer

Mark is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.