Introduction
Recently, we implemented a SharePoint site design using a PowerShell script for a Postal and Parcel company based out of Melbourne, Victoria, Australia. We encountered an issue while applying the site script and site design during the execution of Add-PnPSiteScript and Add-PnPSiteDesign commands.
In this blog, we will learn about the issue and its solution that
we can implement while creating a new site design template using
the PowerShell script.
Issue
- We normally use the Add-PnPSiteScript and Add-PnPSiteDesign commands to add a new Site Script and Site Design on a SharePoint tenant.
- When we execute these commands frequently on the same tenant, a new Site Script is being created every time.
- And after some time, we encounter these below issues during the execution of the PowerShell script.
- It says “Specified argument was out of the range of valid values”.
Solution
This issue is occurring because there is a tenant level limitation in SharePoint that we can create max of 100 Site Scripts and 100 Site Designs templates.
- To resolve these issues, first of all, we need to remove some of the unused Site Scripts and Site Designs so that we can add our new Site Scripts and Site Designs.
- To remove a Site Script and Site Design, we will be using the below commands.
Remove-PnPSiteScript -Identity $scriptID -Force
Remove-PnPSiteDesign -Identity $designID -Force
- Here the $scriptID & the $designID is the ID of the existing Site Script and Site Design that is been available at the SharePoint tenant level.
- The –Force in the Remove command is used to confirm the execution of this command without asking for confirmation to remove for its execution.
- We cannot view these IDs directly from the SharePoint tenant, so we will be using the below commands to retrieve the details of these IDs.
Get-PnPSiteScript
Get-PnPSiteDesign
- The Get-PnPSiteScript & the Get-PnPSiteDesign commands will retrieve the available Site Scripts and Site Design details and we will extract these details, identify unused Site Script/Site Design and will be using them for removing the existing unused Site Design and Site Scripts.
- And then, it should allow creating your new Site Design and Site Script by executing the Add-PnPSiteScript and Add-PnPSiteDesign commands.
Very Nice Blog.. keep it up..
ReplyDelete