December 2, 2021

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

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. 

    Image 1


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

      Conclusion

      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.

      November 18, 2021

      Microsoft Loop - Quick Overview

      Overview

      At Ignite 2021, the most promising announcement was around Microsoft Loop. In this short blog, we will talk about what Microsoft Loop offers?

      What is Microsoft Loop?

      Microsoft Loop is a new app that combines powerful and flexible canvas with portable components that move freely and stay in sync across apps which enables teams to think, plan, and create together. Microsoft Loop consists of three elements.
      • Loop Components
      • Loop Pages
      • Loop Workspaces
      Let’s explore more in detail!

      Loop Components:

      • It’s an evolution of Fluid components
      • It can be as simple as lists, tables, notes, tasks, or as sophisticated as a customer sales opportunity from Microsoft Dynamics 365
      • It’s synced across all the apps – no matter which app you are using.
      • Examples: Maintain Tasks, Capturing Votes, Add Live Status from D365 Entities

      Loop Pages:

      • Loop pages are flexible canvases where we can organize our components and pull in other useful elements like files, links, or data. 
      • Pages are optimized for thinking together and getting work done. 
      • People can add their ideas, collaborate, add reactions and take proper decisions.
      • Examples: Live Discussions for Project.

      Loop Workspaces:

      • Loop workspaces are shared spaces that allow us and our team to see and group everything important to our project. 
      • Workspaces make it easy for us to catch up on what everyone is working on, react to others’ ideas, or track progress toward shared goals. 
      • Teams can collaborate synchronously or asynchronously whenever inspiration strikes. 

      References:

      Conclusion:

      It’s the first look at Microsoft Loop! Excited for another announcement? Stay tuned! 

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

      October 28, 2021

      How to get list of web parts from Modern SharePoint Page?

      Introduction:

      In this blog, we will learn how can we get web parts added to the Modern Sitepage.
      On the classic page, we can get a list of all web parts using "?contents=1" query string, but it will not work for modern web parts. For the modern web part, we need to use the PowerShell script.

      Script:

      Step 1: First we will read the URL of the site of which page we want to get the web parts.
       $siteURL = Read-Host "Provide site url";  
      
      • Here we are taking user input for site URL, we can also give static Site URL.

      Step 2: Now we will connect to the site using the Connect-PnPOnline command. 
       Connect-PnPOnline -Url $siteURL  
      • This command will ask for credentials.

      Step 3: Now we will get the page using "Get-PnPClientSidePage" command.
       $page = Get-PnPClientSidePage -Identity 'Home'  
      
      Here we are using the Home page, we can use the name of any of your page.

      Step 4: In $page will have all the information for the Home page. So now we will get all web parts available on this page as below:
       $webParts = $page.Controls   
      

      Step 5: Now $webParts will have a list of all web parts available on the Home page. So we will use a loop to read each web part information:
       foreach($webpart in $webparts) {   
         Write-Host "WebPart Id "   
         $webpart.InstanceId   
         Write-Host "Title "   
         $webpart.Title   
       }  
      

      Here we are fetching the web part ID and web part name. 

      Step 6: Complete PowerShell script will be as below:
       $siteURL = Read-Host "Provide site url"   
       Connect-PnPOnline -Url $siteURL  
       $page = Get-PnPClientSidePage -Identity 'Home' #Get the page on which you are going to perform add and remove web parts.  
       $webParts = $page.Controls   
       #if there are more than one webparts   
       foreach($webpart in $webparts) {   
         Write-Host "WebPart Id "   
         $webpart.InstanceId   
         Write-Host "Title "   
         $webpart.Title   
       }  
      
      This PowerShell will give output as below screenshot:



      It will return Custom as well as OOTB web parts.

      Conclusion:

      This is how we can get a list of web parts. Hope this helps!

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