Skip to main content

Site Provisioning in SharePoint Online Step-By-Step Guide

Site Provisioning in SharePoint Online - Step-by-Step Guide

Site Provisioning in SharePoint Online - Step-by-Step Guide

Author: Vishal Thakur

Introduction

Site Provisioning or Site Templating is a developer-friendly feature of SharePoint. Using Site Templating, SharePoint allows you to create a replica of a Site Collection and use it to create similar sites for departmental or other purposes. It is easy to create and apply, requiring a one-time operation. However, there are some prerequisites to using it:

  • Knowledge of PowerShell Scripts.
  • Knowledge of PnP Module.
  • Must have SharePoint Online Administrator credentials.

Step 1: Open PowerShell in Administrator Mode

Start by opening PowerShell in Administrator mode.

Step 2: Install the PnP Module

Run the following command to install the PnP module:

Install-Module -Name "PnP.PowerShell"

Step 3: Connect to SharePoint Online

Run the following command to connect to your SharePoint Online site:

Connect-SPOService -Url https://rb500-admin.sharepoint.com

After running the command, you will be prompted to enter your SharePoint admin credentials.

Step 4: Generate Site Script

Run the following command to generate a site script from an existing site:

Get-SPOSiteScriptFromWeb -WebUrl "https://test.sharepoint.com/sites/mysite" -IncludeTheme -IncludeBranding -IncludeSiteExternalSharingCapability -IncludeRegionalSettings -IncludeLinksToExportedItems -IncludedLists ("SiteAssets", "SitePages", "Lists/Tools", "Lists/Tips", "Lists/Quick Links List", "Lists/Highlights", "Lists/Footer Links", "Lists/Alerts", "Lists/Company News", "Lists/Article News", "Lists/Dashboard")

Step 5: Create JSON File

Copy the output generated by the above command and create a new JSON file named myProvisioning.json. Paste the copied content into this file, excluding the last line.

Step 6: Connect to PnP Online

Run the following command to connect to PnP Online:

Connect-PnPOnline -Url "https://test.sharepoint.com/sites/mytest" -Interactive

Enter your credentials when prompted.

Step 7: Get Installed Apps

Run the following command to list the apps installed on your tenant:

Get-PnPApp

Copy the component IDs of the apps you want to include in your template.

Step 8: Add Component IDs to JSON

Add the component IDs to the JSON file in the following format:

{
    "verb": "installSolution",
    "id": "10688609-079b-4b54-aeab-9768be2d7984"
},
{
    "verb": "installSolution",
    "id": "15368b1d-9ebb-4a94-9920-c57893795441"
},
{
    "verb": "installSolution",
    "id": "26b0d083-c2a1-4eb7-a070-97c985f0cc6d"
}
    

Paste this at the end of the myProvisioning.json file.

Step 9: Add Site Script

Run the following command to add the site script:

Get-Content "D:\PowerShell Scripts\myProvisioning.json" -Raw | Add-SPOSiteScript -Title "MySiteHomeSiteTemplate"

Copy the ID generated by this command.

Step 10: Add Site Design

Run the following command to add the site design:

Add-SPOSiteDesign

Provide the following details when prompted:

  • Title: The name of your template.
  • WebTemplate: Use 64 for a team site or 68 for a communication site.
  • SiteScripts[0]: Paste the ID generated in Step 9.

Step 11: Apply the Template

To apply the template to a new or existing site:

  1. Go to the site where you want to apply the template.
  2. Click on the gear icon and select Site Template.
  3. Select your template from the list and apply it.

Step 12: Delete an Existing Template

To delete an existing template, run the following command with the specific ID:

Remove-SPOSiteDesign <ID>

For example:

Remove-SPOSiteDesign 21209d88-38de-4844-9823-f1f600a1179a

Conclusion

This guide provides a step-by-step process for site provisioning in SharePoint Online using PowerShell and the PnP module. By following these steps, you can create and apply site templates efficiently.

Thanks for Referring!

Comments

Popular posts from this blog

Power Apps modern driven app Interview Question and answer

Power Apps Modern Driven App: Questions and Answers Power Apps Modern Driven App: Questions and Answers Power Apps modern driven apps are low-code/no-code platforms that enable users to create custom applications. Below are some common questions and detailed answers to help you understand their capabilities and applications. Question 1: What is a Power Apps modern driven app? Answer: A Power Apps modern driven app is a low-code/no-code application development platform provided by Microsoft. It allows users to create custom applications that can run on various devices and platforms without extensive coding. These apps are built using a visual interface and can integrate with different data sources. Question 2: What are the key components of a Power Apps modern driven app? Answer: The key components of a Power Apps modern driven app are: Screens: Serve as the user interface for the app, including layouts, ...

SPFX Interview question for 2023

SPFx Interview Questions for 2023 SPFx Interview Questions for 2023 Author: Vishal Thakur Question 1: What is SharePoint Framework (SPFx)? Answer: SharePoint Framework (SPFx) is a development model introduced by Microsoft for creating client-side web parts and extensions for SharePoint Online and SharePoint 2019. It is based on modern web technologies like JavaScript, TypeScript, and React, providing a rich and responsive user experience. Question 2: What are the key advantages of using SPFx for SharePoint development? Answer: SPFx offers several advantages, such as: Responsive and mobile-ready web parts and extensions. Seamless integration with SharePoint data and services. Support for modern web development practices and tools. Easy deployment and hosting options. Enhanced security and isolation through the SharePoint app model. Question 3: Can you explain ...

Interview Questions of SPFx SharePoint

SPFx Interview Questions and Scenarios SPFx Interview Questions and Scenarios By Vishal Thakur What is SPFx? The SharePoint Framework (SPFx) is a web part model that provides full support for client-side SharePoint development. It integrates seamlessly with SharePoint data and extends Microsoft Teams. SPFx allows developers to use modern web technologies and tools in their preferred development environment to build responsive and mobile-ready experiences. Scenario-Based Questions Scenario 1: External API Integration Scenario: Your team is developing an SPFx web part that needs to retrieve data from an external API and display it on a SharePoint site. The API requires authentication using OAuth 2.0. The web part should also allow users to refresh the data manually. Question: How woul...