Tribridge Connections

A Technology, Cloud Solutions & Industry Expertise Blog


Create a Killer SharePoint Provisioning Template in 6 Easy Commands

Published: December 19, 2016
Chad Dyess is a Technical Manager for Velocity Solutions at Tribridge. Read More

Do you have departments in your company that often repeat certain jobs or projects? Of course you do. It’s the nature of business. Your marketing team runs campaigns with similar elements. Or your project managers have several projects going on at once with many moving parts.

Provisioning templates are the perfect way to create a reusable template from your SharePoint site that always includes the document libraries, content, task lists, project statuses, and more, that you want to include within each of these repeatable sites.

And great news –provisioning templates are included with the SharePoint PnP (patterns and practices) Framework. These templates replace the site templates of SharePoint 2013, and are much more versatile and portable. For instance, if you add something to your provisioning template, such as a task list, you can apply this change to all of the sites that you have created, and this was not possible with the old site templates.

You can create a killer provisioning template in PowerShell in six easy commands:

This post will use PowerShell, since it's the easiest tool for ramping up, but the same can be done in Visual Studio if you prefer. The only difference is the libraries that you need to install. First you’ll need to create your source site:

  • First, download and install the PowerShell PnP Provisioning cmdlets. Updates are released each month, so you should check back often to keep up with the latest functionality and bug fixes. Note that there are separate MSI packages for SharePoint 2013, SharePoint 2016, and SharePoint Online, and each must be used specific to the platform you are using. In our example code below, we are using SharePoint Online, so all you need for this demo is the SharePointPnPPowerShellOnline.msi.
  • After you have installed the provisioning cmdlets, you're almost there. You just need to start with a template site that you want to use for your source template. Start with something easy like a standard team site, but try adding a list or library, maybe a site column or a new page. Put some web parts on the home page. Change the theme too.
Once your template site is ready, open PowerShell and run these six commands to create a provisioning template from your source site.


1. #Create the connection to the source site
Connect-PnPOnline -Url <PATH TO YOUR TEMPLATE SITE> -credential <USERNAME>

2.  #Create a template file from the existing site
Get-PnPProvisioningTemplate -Out "C:\PnPTemplates\SampleProvisioningTemplate.pnp" -PersistBrandingFiles -PersistPublishingFiles -IncludeNativePublishingFiles  

3. #Create a new site collection in Office365 (Optional – you can skip steps 3 and 4 if you want to apply the template to an existing site or site collection.) Connect-PnPOnline -Url <OFFICE 365 TENANT ADMIN URL> -credential <USERNAME>

4. New-PnPTenantSite -Title "Sample Site" -Url <NEW SITE COLLECTION PATH> -Owner <USERNAME OF SITE OWNER> -TimeZone 10 -Lcid 1033 -Template "STS#0" -StorageQuota 1000 -RemoveDeletedSite

*NOTE: You have to wait until the site collection is created before you can execute these steps 5 and 6

5. Create the connection to the target site
Connect-PnPOnline -Url <TARGET SITE URL> -credential <USERNAME>

6.
Apply the template file to the target site
Apply-PnPProvisioningTemplate -Path "C:\PnPTemplates\SampleProvisioningTemplate.pnp"  

For additional testing, once you've created your new site, go back and change the source site. Add some new lists, views, columns, pages, etc. Change the look again. Rearrange the web parts on the home pages. Now rebuild your provisioning template and apply it to your existing destination site. Your new site will be updated to include the new structure. You can't do that with the old site template! Exciting stuff!

Of course, you can always reach out to Tribridge if you need help creating a Sharepoint strategy that works best for your organization.

Share Your Thoughts With Us

Load more comments
Thank you for the comment! Your comment must be approved first


Related Insights

Microsoft Envision: September 25-27, 2017
Published: April 07, 2017
Event Date: September 25, 2017

Microsoft Envision, the event for business leaders, will now align with Microsoft Ignite, September 25-29. The partnership between business and IT leaders has never been more important; Microsoft Ignite will now cater to both audiences and help...

Live Events & Webinars