Configure

Allow custom scripts in SharePoint online site

This sample script shows how to allow use of custom scripts in SharePoint online at site level

Summary

This sample script shows how to allow use of custom scripts in SharePoint online at site level.

Scenario inspired from this blog post: Allow use of custom scripts in SharePoint Online using PowerShell

powershell

# SharePoint online admin center URL
$adminCenterUrl = "https://contoso-admin.sharepoint.com/"

# SharePoint online site URL
$siteUrl = Read-Host -Prompt "Enter your SharePoint site URL (e.g https://contoso.sharepoint.com/sites/SPConnect)"

# Connect to SharePoint online admin center
Connect-SPOService -Url $adminCenterUrl

# Allow custom scripts on SharePoint online site
Set-SPOSite $siteUrl -DenyAddAndCustomizePages 0

# Disconnect SharePoint online connection
Disconnect-SPOService

Contributors

Author(s)
Ganesh Sanap

Disclaimer

THESE SAMPLES ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.

Tool documentation & references

Keep exploring