How can we help you today?

Enable Scripting Capabilities with PowerShell for Microsoft 365

If you are trying to install ShortPoint on your SharePoint site, and you came across an error message saying that you have to enable scripting capabilities to finish the installation, then this article is for you.


Scripting capabilities are not enabled with modern sites (and other sites) by default, and cannot be enabled using the admin portal for modern sites. You cannot install ShortPoint Add-In on modern sites if scripting capabilities are not enabled.  The only way to enable scripting capabilities is through PowerShell


NOTEStarting November 2024, Microsoft will make it very hard to keep Scripting Capabilities enabled on SharePoint Sites. 

They are currently automatically disabling Scripting Capabilities every 24 hours unless you run the command outlined here under Persist custom script settings.

However, starting November 2024, this command will no longer work, which means that you will need to manually run a script daily to enable scripting capabilities.

We highly recommend migrating your SharePoint Environment from Classic Sites and Pages to Modern Sites and Pages. 

You may reach out to our support team for recommendations on how to do this. You can contact us by sending an email to support@shortpoint.com or by submitting a ticket.

We also recommend migrating off of SharePoint add-ins that require Scripting Capabilities to function. Note that ShortPoint doesn't require Scripting Capabilities to run on Modern Sites and Pages.




NOTEStarting March 2024, Microsoft removed the ability to enable scripting capabilities in the SharePoint admin center. 


Custom Script in Admin Center


Users can still enable this option through PowerShell but migrating off Classic Pages and Sites is highly recommended (Please read the note above).


TABLE OF CONTENTS


Before we begin


Prerequisites


How to enable scripting capabilities with PowerShell


Follow the steps below to enable scripting capabilities on your Microsoft 365 SharePoint site:


Step 1: Open SharePoint Online Management Shell


From your computer, open SharePoint Online Management Shell.


Open SharePoint Online Management Shell


Note: If you do not have the SharePoint Online Management Shell application on your computer, kindly go back to the prerequisite guidelines to learn how to download and install it.

Step 2: Connect and sign in to your SharePoint Admin Portal


On SharePoint Online Manage Shell, type the following command to open connection:


Connect-SPOService


Then, hit the Enter key.


Connect to your SharePoint site

Enter the URL of your SharePoint Admin Portal. Typically, the URL looks like this:


https:// your-domain -admin.sharepoint.com


Replace your-domain with the name of your site domain and hit Enter.


Enter the URL for your SharePoint Admin Portal site

If you are successful in connecting to your site, it will ask you for a username and password. Sign in using the account of the user who has permission to manage SharePoint from the SharePoint Admin Center.


Sign in to you SharePoint account


Step 3: Enable scripting capabilities on your a specific site


Type the following command to enable scripting capabilities on a specific site collection:


Set-SPOsite https:// your-domain .sharepoint.com/sites/modern-site -DenyAddAndCustomizePages 0


Replace

  • your-domain  with the name of your site domain.
  • sites/modern-site with the path of your modern site.


To save time, you can run the same command automatically on all of the active sites in your tenant by following the instructions in the next section: "Programmatically enable scripting capabilities on every active site in your tenant"



Enabling scripting capabilities on your site


Then, hit the Enter key.


Step 4: Persist custom script settings


To prevent SharePoint from resetting custom script settings to its original value, run the following command in PowerShell:


Set-SPOTenant -DelayDenyAddAndCustomizePagesEnforcement $True


NOTEStarting November 2024, this command will stop working as outlined in the Persist custom script section.

For this reason, we highly recommend moving your pages from Classic Sites and Pages to Modern Sites and pages to avoid disruption. We also recommend to stop relying on add-ins that require scripting capabilities to be enabled to run.

ShortPoint does not need Scripting Capabilities to run on Modern Sites and Pages.


That's it! You have now enabled scripting capabilities in Microsoft 365. You will now be able to install ShortPoint on Modern or Classic Sites.



Programmatically enable scripting capabilities on every active site in your tenant

In case you have a lot of sites that you want to enable scripting capabilities on and don't want to write each site's name then you can do the following:


In the same SharePoint Online Management Shell, after logging in like outlined above, run the following command to generate a list of all of the active sites in your tenant:


Get-SPOSite -Limit ALL | Select Url | Export-Csv C:/temp/all-active-sites.csv -NoTypeInformation


This command will generate a csv list of all of the sites that are there in your tenant and place it in C:/temp/ (you can delete this later)


Then you can run the following lines to enable scripting capabilities on each site that's listed in the CSV file (copy and paste all of this text into the SharePoint Online Management Shell window then hit enter):


$siteUrls = Import-Csv -Path "C:/temp/all-active-sites.csv"; Set-SPOTenant -DelayDenyAddAndCustomizePagesEnforcement $True; foreach ($site in $siteUrls) { Write-Host "Running command on site: " $site.Url; Set-SPOSite -Identity $site.Url -DenyAddAndCustomizePages 0; };

To Stop Scripting Capabilities Being Disabled After 24 Hours

If you encounter an issue where the ShortPoint Web Part and the ShortPoint Dashboard is not loading because Scripting Capabilities was forcefully disabled by SharePoint after 24 hours, then follow the steps below:


First make sure you did the steps shown above (How to enable scripting capabilities with PowerShell) and make sure to repeat the 4th step (Step 4: Persist custom script settings).


failed loading


Please read the notice about SharePoint deprecating the "Scripting Capabilities Persistence" command for MS 365 environments in November at the top of this article and keep in mind that we highly recommend transforming Classic Pages to Modern Pages to avoid these issues in the future (In addition to many other benefits).


Read more about this in this article: How to Transform a Classic SharePoint Page into Modern


Disabling scripting capabilities on your site


In the event that you want to disable scripting capabilities on your site, you may repeat the steps in this article. However, for Step 3, replace the command with:


Set-SPOsite https://your-domain.sharepoint.com/sites/modern-site -DenyAddAndCustomizePages 1


Replace

  • your-domain  with the name of your site domain.
  • sites/modern-site with the path of your modern site.

Related articles:

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.

World's best intranet sites are designed using ShortPoint

Get started today! Learn more
See all 8 topics

Start a trial

Ignite your vision. Install ShortPoint directly on your site, or play in sandbox mode. No credit card required.

Get started today

World’s best intranet sites are designed using ShortPoint

Thousands of companies using ShortPoint everyday to design, brand and build award winning intranet sites.

Get started Learn more