# How to Enable Custom Script for SharePoint Online Modern Site
If you create a SharePoint On-Premise site and go to its Site Settings page, the "Web Designer Galleries" section appears like this:
But when you create a new SharePoint Online Modern Site, the “Web Designer Galleries” section shows very limited options:
Modern SharePoint Option
If you want your Modern Site to show all options similar to an On-Premise site, you can enable them using PowerShell. Follow the steps given below:
1. Open PowerShell: First, open “Windows PowerShell ISE” by selecting Run as Administrator.
2. Set Execution Policy: If you are using PowerShell for the first time, allow permission to run commands:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
After this, click on “Yes to All”.
3. Install SharePoint Module: Install the module needed to communicate with SharePoint Online:
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
4. Credentials Setup: Create a variable to store admin credentials:
$cred = Get-Credential
Enter your SharePoint Online Admin username and password in the pop-up that appears.
5. Connect to Service: Now connect to the SharePoint Admin Center:
Connect-SPOService -Url "https://yourtenant-admin.sharepoint.com" -Credential $cred
6. Enable Custom Script: Run the final command to enable all hidden options:
Set-SPOSite "https://yourtenant.sharepoint.com/sites/yoursite" -DenyAddAndCustomizePages 0
-DenyAddAndCustomizePages 0 means Custom Scripting is ON.
To disable it again, replace 0 with 1.
7. Verify: Refresh the Site Settings page — you will now see all the additional options.
8. Disconnect: After completing the task, disconnecting the service is a good practice:
Disconnect-SPOService
Full Code Snippet (Quick Copy)
# 1. Set Policy
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
# 2. Install Module
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
# 3. Store Credentials
$cred = Get-Credential
# 4. Connect (Change URL)
Connect-SPOService -Url "https://eminence2019-admin.sharepoint.com" -Credential $cred
# 5. Enable Options (Change URL)
Set-SPOsite "https://eminence2019.sharepoint.com/sites/codigo" -DenyAddAndCustomizePages 0
# 6. Disconnect
Disconnect-SPOService
1 Comments
Wow, we can covert SharePoint modern to classic that's mean i will get content editor web part. is it right?
ReplyDeleteThanks!