In this post we look at how you can allow or block custom scripts in SharePoint via the admin center, what’s changed and other ways enable.

I was recently running a migration job in Sharegate when I received the below error message:
“Enable custom script setting at the destination to copy *.ASPX files.”
ShareGate’s support article details that Microsoft 365 does not allow ShareGate Migrate to upload files that could potentially contain custom scripts if the custom script feature is not activated. It goes on to explain that ShareGate can’t do this automatically and it requires someone with admin privileges to do so manually.

My example was duringa routine page migration from one SharePoint site to another, ShareGate threw an error stating that custom scripting was not enabled for the target site. The issue wasn’t the page itself, but rather the site hadn’t been granted permission to run any form of custom script, which SharePoint Online blocks by default.
This article from Microsoft states that custom script capabilities are disabled by default to protect tenants, requiring explicit admin roles to allow. A global admin setting previously allowed custom scripts until November 2024, when an update specified that while custom script remains enabled via PowerShell, it may take up to 24 hours for changes to appear on sites. Microsoft’s updated messaging encourages admins to consider enabling custom script as an exception, reinforces that it remains off by default for newly created sites, highlights security risks, and clarifies scenarios when custom script is needed.
How to enable custom scripting via the SharePoint admin center
- Navigate to the SharePoint admin center > active sites > select the site in question
- Select the Settings tab > under Custom Scripts > Edit
- Change the setting to Allowed > Save

Enable custom script via PowerShell
Use the cmdlet below to do the same thing, but via PowerShell:
Connect-SPOService -Url https://<tenant>-admin.sharepoint.comSet-SPOSite -Identity https://<tenant>.sharepoint.com/sites/<yoursite> `-DenyAddAndCustomizePages 0
- Setting
DenyAddAndCustomizePagesto 0 allows custom script. Setting it back to 1 disables it again.
Does the PowerShell method last longer than 24 hours?
In short, yes they do persist indefinitely. However, the visibility of the change in the UI still takes up to 24 hours to reflect this change. A reply in this Microsoft Q&A thread clarifies the positon:
- The setting remains in effect until you change it back.
- The 24‑hour reference is simply about when the change becomes fully active across all SharePoint services.
So, if you’re migrating site pages, or anything that contains custom script you will get the “custom script not enabled” error. The November 2024 updates on how custom script behaves in SharePoint helps avoid confusion, but you will still need to manually enable it as an admin from time to time.





Leave a Reply