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
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")
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
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
"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
Once you pasted it in the above format, you must copy it and paste to the end of the myProvisioning.json file.
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
Step 11: Run the below command
It will ask some questions, please provide it will ask Title, Web Template, and SiteScripts
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 - 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
Thanks for referring It.
Post a Comment