Enable custom scripting on SharePoint Online using PowerShell

Emmanuel Adegor
2 min readFeb 13, 2023

--

PowerShell is a powerful scripting language that is commonly used for managing SharePoint Online. It provides a range of cmdlets that allow administrators to automate tasks, manage sites, and perform other administrative functions on SharePoint Online.

Prerequisites

To enable custom scripting on SharePoint Online, you will need to have the following:

  • A SharePoint Online subscription.
  • A Windows computer with PowerShell installed.
  • Global administrator permissions on your SharePoint Online tenant.\

Now let’s ride

Photo credit: www.dreamworks.com

Connect to SharePoint Online

Before we can enable custom scripting on SharePoint Online, we need to connect to it using PowerShell. To do this, we will use the Connect-SPOService cmdlet.

Open PowerShell and run the following command:

Connect-SPOService -Url https://<tenant>-admin.sharepoint.com -Credential (Get-Credential)

Replace <tenant> with the name of your SharePoint Online tenant. You will be prompted to enter your credentials. Enter the credentials of a global administrator for your SharePoint Online tenant.

Once you have successfully connected to SharePoint Online, you can proceed to enable custom scripting.

Enable Custom Scripting

To enable custom scripting on SharePoint Online, we will use the Set-SPOsite cmdlet.

Run the following command to enable custom scripting:

Set-SPOsite -Identity https://<tenant>.sharepoint.com -DenyAddAndCustomizePages 0

Replace <tenant> with the name of your SharePoint Online tenant.

This command sets the DenyAddAndCustomizePages property of the SharePoint site to 0, which means custom scripting is allowed. By default, this property is set to 1, which means custom scripting is not allowed.

Conclusion

Custom scripting can greatly enhance the functionality of SharePoint Online and enable businesses to meet their specific needs. By following the steps outlined in this article, you can enable custom scripting on SharePoint Online using PowerShell. With custom scripting, you can automate tasks, add new features, and integrate with other systems to improve the overall efficiency of your SharePoint Online environment.

Photo credit: https://gamerbraves.sgp1.cdn.digitaloceanspaces.com

--

--

Emmanuel Adegor
Emmanuel Adegor

Written by Emmanuel Adegor

Principal Software Engineer/Architect ( M365 SharePoint | Teams | SPFX ) | Collaboration Platforms | Workflow Automation Expert

No responses yet