How to enable scripting capabilities with PowerShell

Applies To: SharePoint Online

Description

Crow Canyon NITRO Studio requires that custom scripting should be enabled in the SharePoint site.

Please refer this Microsoft article to enable scripting from the SharePoint admin center. It takes about 24 hours for this change to take effect for the sites. To enable scripting immediately for the site using PowerShell, please follow the detailed steps given below. Note that enabling the scripting from SharePoint admin center is still required as otherwise it overrides the settings done using PowerShell (in about 24 hours).

Steps to enable scripting using PowerShell

  1. Download and Install Windows Management Framework 5.1 (if the Operating System is not Windows 10)
  2. Download and Install SharePoint Online Management Shell
  3. Open SharePoint Online Management Shell from Windows Start Menu
  4. Connect to your SharePoint Admin Portal

  • Sign in
  • Enter the username and password for the user who has tenant admin permissions5. Enable Scripting Capabilities on your site

Step 1: Update site collection property to enable scripting

  • Enter the following command to enable scripting capabilities on your site:
    • Set-SPOsite <Site Collection URL> -DenyAddAndCustomizePages 0
  • We need to enter the site collection URL for <Site Collection URL>
    • E.g. Site Collection URL: https://your-tenant-name.sharepoint.com/sites/site1

Step 2: Persist custom script settings

  • Step 1 above will enable scripting capabilities for the site only for 24 hours and SharePoint resets it to blocked state.
  • To avoid SharePoint resetting custom script settings, below command need to be run in SharePoint Online Management Shell
    • Set-SPOTenant -DelayDenyAddAndCustomizePagesEnforcement $True
      
      
      

Leave a Reply