A project lead asked me for one thing: “Save site as template” on our classic SPGuidesClassic team site. The link wasn’t there, because custom script is blocked by default. To enable custom script on a SharePoint Online site, you set it to Allowed in the admin center or with PowerShell.
In this tutorial, we’ll enable custom script in SharePoint Online for that one site: check the setting, allow it with Set-SPOSite or PnP PowerShell, confirm the features that come back, find every allowed site, and block it again.
Here’s what we’re building: the site’s Custom scripts setting switched from Blocked to Allowed.

Everything below ran on 10/25/2026 against a demo site, never a production one. It’s a short, deliberate window, not a permanent change.
Before You Start
Custom script means users can add their own JavaScript or server-side pages to a site. Anyone with the Add and Customize Pages permission (site owners have it) could then add any script, and admins can’t audit or block it afterward. That’s why Microsoft blocks it.
You need the SharePoint Administrator role in Microsoft 365. Here’s the setup I used:
| Item | Value | Notes |
|---|---|---|
| Site | /sites/SPGuidesClassic | Team site (classic experience), template STS#0 |
| PowerShell 7 | 7.6.7 | SharePoint Online Management Shell + PnP.PowerShell 3.3.0 |
| Windows PowerShell | 5.1 | PnP.PowerShell 1.12.0 for the block-again step |
| Starting state | Blocked | DenyAddAndCustomizePages = Enabled |
With custom script blocked, the classic Site Settings page is thin. Web Designer Galleries shows only Site columns and Site content types, and there’s no Save site as template:
