Enabling/disabling custom scripts on site collection using PowerShell

Document created by daniel_wyss_(skybow) Employee on Jul 10, 2017Last modified by daniel_wyss_(skybow) Employee on Jul 10, 2017
Version 3Show Document
  • View in full screen mode

To allow publishing solutions to a site, Solution Studio enables custom scripts on the site collection. This is needed because otherwise some assets (mainly scripts and web parts) required for the solution to run can't be deployed to the site.

If you wish to disable custom scripts for security reasons you can use the following Microsoft PowerShell commands (using the SharePoint Online Management Shell):

Connect-SPOService -Url "https://<SPO tenant name>-admin.sharepoint.com"
Set-SPOsite "https://<SPO tenant name>.sharepoint.com/sites/<Site name>" -DenyAddAndCustomizePages 1

This will disallow adding custom scripts to the given site collection. The previously published solution will still run fine.


For more information also see the following MS article:
Allow or prevent custom script