Skip to main content

Site Provisioning in SharePoint Online Step-By-Step Guide

Introduction: Site Provisioning Or Site Templating is a developer-friendly feature of SharePoint, using Site Templating SharePoint Allows you to create a replica of its Site Collection and can use to create the same for the departmental sites or the other sites.

It is easy to create and smooth to apply, requiring a single-time operation. It has some pre-requisite to use it

1. Knowledge of PowerShell Scripts.

2. Knowledge of PnP Module.

3. Must have SharePoint Online Administrator credential.

Please follow bellow steps.

Step 1: Open PowerShell in the Administrator mode


Step- 2 Run the below commands, it will install the PnP module.

Install-Module -Name "PnP.PowerShell"

Step- 3 Run the below command in PowerShell

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

 After running the above command, it will show you the Login Promote. So, you must put your SharePoint admin credentials, for more details refer to the below screen.

Once you enter the correct credentials, it will be ready for the next step, refer screen below.


Step-4: Run the below commands, these commands specify the list or document library which you want to provision in your template, please copy, paste it and run.

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:

Copy the output generated by the step 4 command and create a new JSON file with the name myProvisioning.json, please refer below screen you must copy content from step 4 till the bottom of the JSON.

Please skip the last line, refer to the below screen

Step 6 - Connect PnP by running the below commands

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

 Once you paste it, it will ask for the user credentials, please enter your credentials here Then you will get, the below screen


Step 7 - Run the below command

Get-PnPApp 

Once you run the above command it will give you the list of apps installed on your tenant, refer to the below screen.

Now what you need to do, you must copy the title id (component id) from here, which you want to provision on your template.

Step 8 – Copy the component Id and paste it below the format

{

                "verb": "installSolution",

                "id": "Put web part id from solution in manifest file or get the web part id from PowerShell Command"

}

For example, We are taking three component Id from here to the provision in the template

For that, I copied three Id’s component and pasted them below in this manner

{

                "verb": "installSolution",

                "id": "10688609-079b-4b54-aeab-9768be2d7984"

},

{

                "verb": "installSolution",

                "id": "15368b1d-9ebb-4a94-9920-c57893795441"

},

{

                "verb": "installSolution",

                "id": "26b0d083-c2a1-4eb7-a070-97c985f0cc6d"

Once you pasted it in the above format, you must copy it and paste to the end of the myProvisioning.json file. 

For Example:

Step 9 – Now run the below command,

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

 Once you run the above command It will show you the below output


Step 10: Now copy the Id from the above output

ID: c3eb7cce-9af2-468c-973b-69c40b0833a8

Step 11:  Run the below command

Add-SPOSiteDesign

It will ask some questions, please provide it will ask Title, Web Template, and SiteScripts[0]


Note: -

Title - put the template name which you desired

WebTemplate - 64 code is team site template code and if you want to convert into communication use this 68

SiteScript[0] - Paste the id from generate by step 9 command (If you want to add multiple scripts so enter and add more script id and want to skip other than press enter key)

It is done. 

Now it’s time to apply it to existing site or the new site 

Step 1 –

Hope you have a new site, now you need to click on the gear icon, at the top of the header and select Site Template, refer to the below screen


 Once you select it you got the below option, now you need to select it.


It will ask you to install the list of components like the below screen

Once you click it, it will take some time to apply

Note: It will not contain the data which are in the original list.

Attached is the JSON file for your reference


How to delete the existing template, execute the below command with the specific ID

Remove-SPOSiteDesign <ID>
Remove-SPOSiteDesign 21209d88-38de-4844-9823-f1f600a1179a 

Thanks for referring It.

 



Comments

Popular posts from this blog

Interview Questions of SPFx SharePoint

What is SPFx? The SharePoint Framework (SPFx) is a web part model that provides full support for client-side SharePoint development, it is easy to integrate with SharePoint data, and extend Microsoft Teams. With the SharePoint Framework, you can use modern web technologies and tools in your preferred development environment to build productive experiences and apps that are responsive and mobile-ready. Scenario Based asking Scenario 1: Scenario: Your team is developing a SharePoint Framework (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 1: How would you approach implementing this functionality in an SPFx web

Interview Question of Advanced SharePoint SPFx

1. What is WebPack? A module bundling system built on top of Node. js framework is known as a WebPack. It is capable to handle the combination and minification of JavaScript and CSS files, also other files such as images by using plugins. WebPack is the recommended way of bundling the files in JS framework and .Net frameworks. In the SPFx it is used with React Js. 2. What is PowerShell.? PowerShell is a platform introduced by Microsoft to perform cross-platform task automation and configuration management framework, it is made up of a command-line shell, a scripting language. it can be run on Windows, Linux, and macOS. 3. What is bundling and Minification? The terms bundling and minification are the processes of code compressing, which is used to improve the load and request time, It is used in modern JavaScript frameworks and .Net frameworks. It improves the load time by reducing the number of requests to the s

Top20 - SharePoint Framework (SPFx) Interview Questions

1.  Which tool we can use to generate a SharePoint Framework (SPFx) solution? Developers can use  Yeoman to generate SharePoint Framework (SPFx) solution, it is a client-side scaffolding open-source tool to help in web-based development. 2. How developer can ensure that the solution deployed was immediately available to all site collections in SPFx?  To ensure the availability of the deployed solution on all the site collections developer has to configure  skipFeatureDeployment: true  in package-solution.json {     "solution" : {       "name" : "theultimateresources-deployment-client-side-solution" ,       "id" : "as3feca4-4j89-47f1-a0e2-78de8890e5hy" ,       "version" : "2.0.0.0" ,       "skipFeatureDeployment" : true     },     "paths" : {       "zippedPackage" : "solution/theultimateresources-deploy-true.sppkg"     }  }