Enable Custom Scripts in SharePoint Sites
How to enable or disable custom scripts for specific SharePoint sites.
Scripting for SharePoint sites can be enabled or disabled at the tenant level. It is recommended to leave it off and only enable scripting for specific sites that require it.
Scripting can be enabled for a specific site collection using PowerShell. [1]
- Download the latest SharePoint Online Management Shell.
- Open SharePoint Online Management Shell.
- Connect to SharePoint as a Global Administrator or SharePoint Administrator in Microsoft 365. To learn how, see Getting started with SharePoint Online Management Shell.
- Run the following command.
Set-SPOSite <SiteURL> -DenyAddAndCustomizePages 0
or, if using PnP.PowerShell:
Set-PnPSite -Identity <SiteURL> -NoScriptSite $false
If you change this setting for a classic team site, it will be overridden by the Custom Script setting in the admin center within 24 hours.
Updated on Jul 27, 2025