SharePoint Online: Apply Theme using PnP Provisioning Template PowerShell

Requirement: Set Theme in SharePoint Online Site using PnP PowerShell Provisioning Template.

How to Change the Site Theme in SharePoint Online using the PnP Provisioning Template?

One of the most effective ways to transform the look and feel of your SharePoint site is by changing the site theme. SharePoint site themes are a collection of colors, fonts, and formatting settings that define the visual appearance of your SharePoint site. By applying a custom theme, you can ensure a consistent and professional look across all pages and elements within your site.

In this comprehensive guide, we’ll explore how to change the site theme using PnP Provisioning Templates. In order to apply a theme to a SharePoint Online site using a PnP Provisioning Template and PowerShell, you will need to complete the following steps:

Step 1: Create a Provisioning Template Schema XML for the Theme

Go to the PnP Provisioning Schema repository in GitHub and build your provisioning template. https://github.com/SharePoint/PnP-Provisioning-Schema, You can also get the template from an existing site using the Get-PnPSiteTemplate cmdlet. Here is mine:

<?xml version="1.0"?>
<pnp:Provisioning xmlns:pnp="https://schemas.dev.office.com/PnP/2019/03/ProvisioningSchema">
  <pnp:Preferences Generator="OfficeDevPnP.Core, Version=3.9.1905.0, Culture=neutral, PublicKeyToken=null" />
  <pnp:Templates ID="CONTAINER-TEMPLATE-a170b11a-d4d3-486f-b191-946ff2acaec3">
    <pnp:ProvisioningTemplate ID="TEMPLATE-a170b11a-d4d3-486f-b191-946ff2acaec3" Version="1" BaseSiteTemplate="SITEPAGEPUBLISHING#0" Scope="RootSite">
      <pnp:Theme Name="Orange" IsInverted="false" />
    </pnp:ProvisioningTemplate>
  </pnp:Templates>
</pnp:Provisioning>

Make necessary changes and save this as an XML file. E.g., Pnp-Theme.xml

Step 2: PowerShell to Apply Provisioning Template

Once the template is ready, apply it to the site using the PnP PowerShell script below.

#Config Variables
$SiteURL = "https://crescent.sharepoint.com"
$TemplateXML  ="C:\Users\salaudeen\Desktop\Pnp-Theme.xml"
 
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#Apply provisioning Template
Invoke-PnPSiteTemplate -path $TemplateXML

After applying the PnP Provisioning Template, verify that the site theme has been successfully updated. Here is the script in action:

set theme in sharepoint online using pnp provisioning template

In summary, changing the site theme in SharePoint Online using PnP Provisioning Templates is a powerful way to create a visually appealing and brand-aligned user experience. By following the steps outlined in this guide, you can successfully transform your SharePoint site and enhance user engagement.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

One thought on “SharePoint Online: Apply Theme using PnP Provisioning Template PowerShell

  • When I follow these instructions, the Invoke command fails with “Template is not valid.” Any thoughts?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *