How do i provision a site policy in SharePoint Online? OnPrem this is done quite easy withtin the xmldocuments but i cant find an easy way to do this online. Can anyone point me in the right direction.

To be clear i dont wanna add CTH.

1 Answer 1


You can use PnP Powsershell to get the provision template which include only the site Policy. this template file is a XML document.

Connect to source web-site

Connect-PnPOnline -Url "https:\\contoso.sharepoint.com\site\my_site"

Get Site Policy

Get-PnPProvisioningTemplate -Handlers SitePolicy -Out D:\sitePolicy.xml

Import the template to target web site after making connection, run this command

Apply-PnPProvisioningTemplate -Path D:\sitePolicy.xml
  • Never thought about that approach, Gonna try tonight, thanks for tip. Jul 8, 2018 at 16:01
  • This only adds a sitepolicy that is already existing. There is no information in the xml that can create the dates or rules that are needed for creating a policy. I wanna be able to set the date for readonly and removing in the xml since they will differ from site to site. Jul 9, 2018 at 8:57
  • This provides you the existing site policy template that can be moved to other sites. But you can still manually Add/edit the policy parameters, attributes etc. Just make sure u don't break the XML structure.
    – DvG
    Jul 9, 2018 at 9:44
  • <?xml version="1.0"?> <pnp:Provisioning xmlns:pnp="schemas.dev.office.com/PnP/2016/05/ProvisioningSchema"> <pnp:Preferences Generator="OfficeDevPnP.Core, Version=2.17.1708.1, Culture=neutral, PublicKeyToken=3751622786b357c2"/> <pnp:Templates ID="CONTAINER-TEMPLATE-38540025935344AAB13754946B37A406"> <pnp:ProvisioningTemplate ID="TEMPLATE-38540025935344AAB13754946B37A406" BaseSiteTemplate="STS#0" Version="1"> <pnp:SitePolicy>test</pnp:SitePolicy> </pnp:ProvisioningTemplate> </pnp:Templates> </pnp:Provisioning> Jul 10, 2018 at 11:26
  • this is what i get from template. No variables to change there Jul 10, 2018 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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