Live training: next batches coming soon. Join the waitlist:Waitlists open:Developer Training →Developer →Copilot Studio Training →Copilot Studio →

How to Enable Custom Script in SharePoint Online (Admin Center and PowerShell)

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.

SharePoint admin center site panel for SPGuidesClassic showing Custom scripts set 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:

ItemValueNotes
Site/sites/SPGuidesClassicTeam site (classic experience), template STS#0
PowerShell 77.6.7SharePoint Online Management Shell + PnP.PowerShell 3.3.0
Windows PowerShell5.1PnP.PowerShell 1.12.0 for the block-again step
Starting stateBlockedDenyAddAndCustomizePages = 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: