Skip to main content
Version: Insiders

Generate a PnP Template for provisioning actions

PnP provisioning templates streamline the creation of custom site structures on provisioned sites. Supported by an active community, the PnP Provisioning Framework offers an open-source solution.

Generating and Applying PnP Provisioning Templates

To generate and apply PnP provisioning templates in SharePoint, you have two options:

  • Use the web interface in EasyLife to generate your PnP Template.
  • Generate your own PnP Template using PnP PowerShell.

Generating a PnP Provisioning XML with PnP PowerShell

PnP PowerShell allows you to create a provisioning XML to configure SharePoint sites. When generating your own PnP provisioning XMLs, consider these important aspects:

  • EasyLife does not support TermGroups due to permission limitations.
  • Some fields may not be provisioned due to permission restrictions (e.g., special site fields).

Below is the PowerShell script to generate a template.xml from an existing site, excluding TermGroups:

info

Ensure $siteUrl and $templatePath variables are updated with your environment's values. Run this script with necessary permissions.

$templatePath = "C:\path\to\your\template.xml"
$siteUrl = "https://yoursite.sharepoint.com/sites/yoursite"

Import-Module PnP.PowerShell
Connect-PnPOnline -Url $siteUrl -Interactive

$template = Get-PnPProvisioningTemplate -Out "template.xml" -ExcludeHandlers TermGroups
Save-PnPProvisioningTemplate -Template $template -Out $templatePath

Disconnect-PnPOnline

Testing Your PnP Template

Create a new site and test your template's functionality with the following script:

Connect-PnPOnline -Url https://targetsite.sharepoint.com/sites/targetsite -Interactive
Apply-PnPProvisioningTemplate -Path "C:\path\to\your\template.xml"
Disconnect-PnPOnline

Uploading the XML to Provisioning Actions

Upload template.xml to SharePoint Provisioning Actions under the PnP Section.

Known Issues

Applying provisioning actions with a PnP template may fail in certain scenarios. Consider these tips:

  • Reduce data in the XML to facilitate smoother provisioning.
  • If "Access Denied" errors occur for SiteFields, modify the XML by removing unnecessary fields under the "SiteFields" node.