Deploy SharePoint Look Book Templates with PnP PowerShell

SharePoint Look Book Templates Deployment

I wanted to experiment with Restricted SharePoint Search for Copilot. To facilitate this, I planned to install some SharePoint Look Book templates. These templates would allow me to differentiate and filter search results more effectively.

However, I discovered that SharePoint Look Book templates are no longer directly deployable to tenants via the SharePoint Look Book. The reason for this change is unclear, but what’s more important is the solution going forward.

New Approach for Installing Look Book Templates: PnP PowerShell

To deploy SharePoint site templates now, we’ll use PnP PowerShell scripts. You can access several templates via the GitHub repository, which contains all the necessary provisioning scripts.

For a full list of available templates, you can refer to this guide.

Example: Adding the Microsoft 365 Learning Pathways Site

For this example, we’ll focus on installing the Microsoft 365 Learning Pathways template. Here’s the process:

  1. Download the Template
    Download the M365LP.pnp file from the GitHub repo: sp-dev-provisioning-templates/tenant/O365Learning and save it locally.
  2. Create a Communication Site
    In your SharePoint tenant, create a ‘Communications Site’ and name it M365LearningPathways. Keep the default settings, as they will be overwritten by the M365LP.pnp template.

PowerShell and PnP PowerShell Setup

  1. Install PowerShell 7.x
    Install the latest version of PowerShell 7.x via Winget. This is the Microsoft-recommended method and ensures that you receive updates. Instructions can be found here.
  2. Run PowerShell as Administrator
    Run PowerShell 7.x in Administrator mode and confirm the version with the following
    $PSVersionTable
    Example output: PSVersion 7.4.5
  3. Install the SharePoint PnP PowerShell Module
    Install the SharePoint PnP PowerShell Online module:
    Install-Module SharePointPnPPowerShellOnline Validate the installation:
    Get-Module SharePointPnPPowerShell* -ListAvailable | Select-Object Name,Version | Sort-Object Version -Descending
    Example output: SharePointPnPPowerShellOnline, Version: 3.29.2101.0

SharePoint Online Management Shell

  1. Import the Management Shell Module
    Import the SharePoint Online Management Shell:
    Import-Module Microsoft.Online.SharePoint.PowerShell -UseWindowsPowerShell
  2. Validate the Module Version
    Check the version of the imported module:
    Get-Module -ListAvailable -Name Microsoft.Online.SharePoint.PowerShell | Select Name,Version
    Example output: Microsoft.Online.SharePoint.PowerShell, Version: 16.0.25221.0
  3. Connect to Your SharePoint Tenant
    Connect to the SharePoint tenant admin site:
    Connect-SPOService -Url https://yourtenant-admin.sharepoint.com

The above validation scripts and outputs – example:

Authentication and Implementation

Before you can authenticate with PnP PowerShell, you need to register an Entra ID Application in Azure. You also need to assign the necessary permissions to it. Instructions for this can be found here.

I recommend using App Only registration to avoid needing to input your credentials repeatedly.

Once the application is registered and permissions are granted, you can connect to SharePoint Online using PnP PowerShell. For this demo, I granted full permissions.
Connect-PnPOnline https://yourtenant-admin.sharepoint.com -Interactive -ClientId 'your-client-id'

Applying the M365 Learning Pathways Template

Now that you’re connected, you can apply the template to the previously created site:
Invoke-PnPTenantTemplate -Path .\data\M365LP.pnp -Parameters @{"SiteTitle"="M365LearningPathways";"SiteUrl"="/sites/M365LearningPathways"} -Verbose

Success!

The Microsoft 365 Learning Pathways site template is now successfully deployed and available in your tenant.

To enable and configure Restricted SharePoint Search for Copilot for Microsoft 365 refer this walkthrough: How to Enable SharePoint Restricted Search and Sites List – Swetha Sankaran


Discover more from QubitSage Chronicles

Subscribe to get the latest posts sent to your email.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.