In SharePoint Online, by default, some of the features are turned off. Features like Save Site as a template, ability to add JS Link and other script-related featured are turned off due to security reasons. If we go to SharePoint online admin center we can allow Custom Scripts on sites which will activate the missing features. In order to do this go to SharePoint Admin Centre ->Settings.Select 'Allow Users to run custom script’ radio buttons. However, selecting allow custom script won’t be enabled until the timer job runs which will happen as per SharePoint Online settings which is something we can’t control . Hence a time period of 24 hours will be required for this to take effect. If we can’t wait that long we can get this activated using PowerShell for SharePoint Online. In order to execute PowerShell commands against SharePoint online, first we have to establish a connection with SharePoint Online. This is done using the command. Connect-SPOService It will ask for the SharePoint Online credentials as shown below. Enter the User name and password to authenticate to SharePoint online. Once the authentication succeeds you will have to enter the admin center url for the “Url“ Parameter as shown above. Once the connection is established, in order to allow custom scripts we can use the below single line cmdlet. Set-SPOsite -DenyAddAndCustomizePages 0. This will enable custom scripts in the site collection and the missing features, like Save list as template, will become available in the UI. Make sure you have set the setting in Admin Center to Allow users to run custom script. If we don’t update this setting, after 24 hours the change made by PowerShell script will be reverted back and custom script will be disabled as the admin center settings supersedes PowerShell update. If we would like to turn off custom script we can use the same cmdlet but with a slight change: We will set the value of DenyAddAndCustomizePages to 1. Set-SPOsite -DenyAddAndCustomizePages 1. Save List as template will again be removed from the UI. Thus we have seen how to enable custom scripts in SharePoint Online using Admin Center as well as PowerShell.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: