kwizcom banner advertisement

How to Enable Custom Script in SharePoint Online?

Requirement: Allow custom script in SharePoint Online!

By default, Custom Scripts are disabled in SharePoint Online for security reasons. So the below features are blocked when the custom scripting is disabled:
  • Many web parts including content editor, script editor, etc are disabled.
  • Uploading files that potentially include scripts are blocked
  • SharePoint Designer script changes not allowed
  • Save Site as Template, Save document library as template links disabled
  • Solution Gallery, Sandbox Solutions, Theme Gallery, HTML Field Settings are not available
  • All other script-related featured are turned off
So, To fix the above problems, we need to enable custom script settings. Here is how to enable custom script in SharePoint Online.

How to Enable Custom Script in SharePoint Online?
To allow custom script in SharePoint Online, follow these steps:
  • Sign in to Office 365 and go to the SharePoint Online Admin Center.
  • Click on Settings from the left navigation >> Scroll down to "Custom Script" section
  • Under Custom Script section, Set "Allow users to run custom script on personal site" and "Allow users to run custom script on self-service created sites" options. 
    enable custom script sharepoint online powershell
  • Click on "OK" to save your changes.
This enables custom script in SharePoint Online. However, this change may take up to 24 Hours to reflect. To enable scripting on a particular site collection immediately, use this PowerShell script through SharePoint Online Management Shell.

Also, when you enable custom scripting through the web interface, you enable it for all sites in the tenant. However, you can enable or disable custom scripting on a specific site collection through PowerShell.

Enable Custom Script in SharePoint Online using PowerShell
#Config Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$SiteURL="https://crescent.sharepoint.com"
  
#Get Credentials to connect
$Cred = Get-Credential
  
#Connect to SharePoint Online Tenant Admin
Connect-SPOService -URL $AdminSiteURL -Credential $Cred
  
#Disable DenyAddAndCustomizePages Flag
Set-SPOSite $SiteURL -DenyAddAndCustomizePages $False

To Disable Custom Script again, use:
Set-SPOsite $SiteURL -DenyAddAndCustomizePages $True
How to Enable Custom Script in SharePoint Online? How to Enable Custom Script in SharePoint Online? Reviewed by Salaudeen Rajack on December 09, 2017 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.