SharePoint Custom Script Turns Off After 24 Hours: Causes and Solutions
Question details
Administrators are finding that the custom script setting in SharePoint Online automatically disables itself 24 hours after being enabled, regardless of whether scheduled PowerShell commands are used to keep it active.
- Product
- SharePoint Online
- Device & OS
- not provided
- Scenario
- Enabling custom scripts for SharePoint sites to support customized workflows or web parts, with the expectation that the setting remains active.
- Observed behavior
- SharePoint Online overrides administrative configurations and automatically reverts the custom script setting back to disabled after exactly 24 hours.
Ensure you have global or SharePoint Administrator privileges to review current site settings and evaluate alternative development frameworks for your tenant.
Migrate to Supported Developer Alternatives
Since Microsoft intentionally enforces a 24-hour reset policy on custom scripts for security reasons, the permanent solution is transitioning to modern SharePoint development frameworks.
SharePoint Online does not provide a permanent setting to keep the legacy custom script feature enabled. Microsoft automatically disables it after 24 hours to protect tenants from malicious script execution and cross-site scripting (XSS) vulnerabilities.
Instead of relying on unsupported workarounds like scheduled PowerShell scripts, administrators should plan a transition to modern, supported development models that do not require custom scripts to be enabled.
Review your SharePoint environment to identify which sites, pages, or web parts are currently failing due to the disabled custom script setting.
Transition your legacy custom functionalities to the SharePoint Framework (SPFx). SPFx is Microsoft's fully supported modern development model that operates securely without needing custom scripts enabled.
If your organization has business-critical legacy applications that cannot be immediately migrated, submit a feature request or support ticket through the Microsoft 365 Admin Center to request extended guidance.
Try WPS Office for Seamless Document Collaboration
While navigating SharePoint's administrative limitations, ensure your team has a reliable and lightweight document editor. WPS Office offers excellent compatibility with Microsoft formats without the complex administrative overhead.
- 1. Download WPS Office: Visit the official WPS website to download the free, lightweight installation package.
- 2. Install the Application: Run the installer and follow the simple on-screen instructions to set up WPS Office on your computer.
- 3. Open and Edit Documents: Launch WPS Office and open your existing .docx, .xlsx, or .pptx files directly, enjoying full format compatibility.

Frequently Asked Questions
Can I use a scheduled PowerShell task to keep SharePoint custom scripts enabled?
While some administrators attempt to use scheduled PowerShell scripts to re-enable custom scripts every 24 hours, Microsoft does not officially support this workaround. It may eventually be blocked or cause performance throttling.
Why does Microsoft disable custom scripts in SharePoint Online?
Microsoft disables the custom script feature by default and forces a 24-hour reset as a strict security measure. This protects SharePoint environments from vulnerabilities such as unauthorized code execution and cross-site scripting.
What are the alternatives to using custom scripts in SharePoint?
The recommended alternative is migrating to the SharePoint Framework (SPFx). SPFx provides a secure, modern, and fully supported way to build custom web parts and extensions without relying on legacy custom script settings.
Does this 24-hour rule apply to SharePoint Server (on-premises)?
No, the automatic 24-hour reset policy is specific to SharePoint Online (Microsoft 365). On-premises SharePoint Server environments still allow administrators to permanently configure and retain custom script settings.




