In this blog, we will be learing about how to export/extract site configurations so that it can be reused in provisioning template.
Get-SPOSiteScriptFromWeb is a SharePoint Online PowerShell cmdlet used to generate a Site Script JSON from an existing SharePoint site (web).
Note that the command will not export page layout, web part configurations, footer, and homepage.
Site Script
A site script is a collection of actions that SharePoint runs when creating a new site or list. Actions describe changes to apply to the new list, such as creating new columns, adding views, or content types. The actions are specified in a JSON script, which is a list of all actions to apply. When a script runs, SharePoint completes each action in the order listed.
Please follow the below steps to generate Site Script JSON:
Step 1: Connect to SharePoint Admin Center
We need SharePoint Admin priviledge as site configuration data is available at tenant level.
Open Windows PowerShell as an Administrator and run the following command to log in:
Step 2: Extract Site Script
Run the following command to extract site structure into Site Script JSON format. This example creates the site script output from an existing site and writes it to a variable.
Parameter details:
| Parameters | Purpose |
|---|---|
| [-WebUrl] <String> | The url that starts with HTTPS of the site to retrieve the site script. |
| [-IncludeBranding] | A switch that if provided, extracts the configuration of the site's branding. |
| [-IncludeTheme] | A switch that if provided, extracts the site's custom theme by using the themeJson property. |
| [-IncludeRegionalSettings] | A switch that if provided, extracts the site's regional settings. |
| [-IncludeSiteExternalSharingCapability] | A switch that if provided, extracts the site's external sharing capability. |
| [-IncludeLinksToExportedItems] | A switch that if provided, extracts navigation links. In order to export navigation links pointing to lists, the list needs to be included in the request as well. |
| [-IncludedLists <String[]>] | An array of one or more lists. Each is identified by the list url. |
Note: All parameters are not mandatory except -WebUrl
Step 3: Save the JSON file
Run the following command to save script content as a JSON file on computer local drive.
Similarly, a SharePoint Teams site (not connected to Microsoft 365 group) configuration can also be extracted.
I hope this will help all of you!
Feel free to provide feedback.
"Happy Coding"



