Applying a Site Template to an Existing Site using PnP PowerShell

Loading

In SharePoint Online, you can apply Site Templates (formerly known as “Site Designs”) to existing sites to quickly configure settings, layouts, lists, libraries, and more. This helps maintain consistency across different sites.

Using PnP PowerShell, you can easily apply a Site Template to an existing site without manually configuring everything through the SharePoint Admin Center.


Prerequisites

Before you proceed, ensure the following:

You have SharePoint Admin or Site Owner permissions.
You have PnP PowerShell installed.
You are connected to SharePoint Online.


Step 1: Install and Import PnP PowerShell

If you haven’t installed PnP PowerShell, install it using:

Install-Module -Name PnP.PowerShell -Scope CurrentUser -AllowClobber -Force

Then, import the module:

Import-Module PnP.PowerShell

Step 2: Connect to SharePoint Online

To manage Site Templates, first connect to SharePoint Online:

Connect-PnPOnline -Url "https://yourtenant-admin.sharepoint.com" -Interactive

Replace "yourtenant" with your actual tenant name.

For app-based authentication, use:

Connect-PnPOnline -Url "https://yourtenant-admin.sharepoint.com" -ClientId "Your-App-Client-ID" -Tenant "yourtenant.onmicrosoft.com" -CertificatePath "Path\To\Certificate.pfx"

Step 3: List Available Site Templates

Before applying a Site Template, check which templates are available in your tenant:

Get-PnPSiteTemplate

This command returns a list of built-in and custom Site Templates with their IDs and Titles.


Step 4: Apply a Site Template to an Existing Site

Once you have identified the Site Template you want to use, apply it to an existing SharePoint site using:

Invoke-PnPSiteDesign -Identity "<SiteTemplateID>" -WebUrl "https://yourtenant.sharepoint.com/sites/YourSite"

🔹 Replace "<SiteTemplateID>" with the ID of the Site Template you want to apply.
🔹 Replace "YourSite" with the actual site name.

The Site Template configurations will be applied automatically.


Step 5: Verify the Applied Site Template

To confirm that the Site Template was successfully applied:

Get-PnPSiteDesignRun -WebUrl "https://yourtenant.sharepoint.com/sites/YourSite"

This command shows the status of applied Site Templates on the given site.


Step 6: Remove a Site Template from an Existing Site

If you need to remove or reset an applied Site Template:

Remove-PnPSiteDesign -Identity "<SiteTemplateID>"

This removes the Site Template, but any created lists, libraries, or changes made by the template will remain.


Common Errors & Troubleshooting

ErrorCauseSolution
No Site Templates foundNo custom templates existUse Get-PnPSiteTemplate to list available templates
Access DeniedInsufficient permissionsEnsure you have SharePoint Admin or Site Owner access
The specified Site Template does not existWrong IDVerify the Site Template ID using Get-PnPSiteTemplate
Cannot connect to SharePoint OnlineAuthentication issuesUse -Interactive login or App-based authentication

Step 7: Disconnect the PowerShell Session

After applying the Site Template, securely disconnect the session:

Disconnect-PnPOnline

This prevents unauthorized access.

Leave a Reply

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