December 2, 2021

[Issue Resolved]: "Specified argument was out of the range of valid values" while executing Add-PnPSiteScript and Add-PnPSiteDesign PowerShell commands


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. 


    • 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. 

    Image 1

    • It says “Specified argument was out of the range of valid values”. 


      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.


      • 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.


      This is how we can resolve the "Specified argument was out of the range of valid values" error in the PowerShell script. Hope this helps, good day! 

      If you have any questions you can reach out our SharePoint Consulting team here.

      1 comment: