Step 1 — Check & Disable the Baseline Security Mode Policy
Microsoft 365 includes a Baseline Security Mode feature that provides tenant-wide security hardening policies. One of its settings — "Don't allow new custom scripts in SharePoint sites" — permanently blocks custom scripts across all SharePoint and OneDrive sites when turned on.
IMPORTANT: If this tenant-level policy is active, any per-site override you want to make via PowerShell will be blocked. You must disable this policy first before enabling custom scripts at the site level.
How to access Baseline Security Mode settings
- Sign in to the Microsoft 365 admin center (admin.microsoft.com).
- In the left navigation bar, select Show all, then expand Settings.
- Under Settings, select Org Settings.
- On the Org Settings page, select the Security and Privacy tab.
Select Baseline Security Mode.
- Click on the "Open Baseline security mode" button at the buttom in the right panel.
- Scroll to the Authentication section and locate the setting "Don't allow new custom scripts in SharePoint sites".
If this setting is On (enabled), toggle it Off to allow custom scripts at the site level.
- Save your changes.
Note: You need the SharePoint Administrator role (or higher) to manage this setting. Baseline Security Mode supports role-based access control, so confirm you have the appropriate role before proceeding.
Step 2 — Enable Custom Scripts via SharePoint Online Management Shell
Once the tenant-level Baseline Security Mode policy is off (or was never enabled), you can enable custom scripts on a specific site collection using the SharePoint Online Management Shell.
Step 2a: Connect to your SharePoint Online tenant
Open PowerShell and connect to your SharePoint Online admin endpoint:
- Replace <SPO tenant name> with your actual tenant name (e.g. contoso).
Connect-SPOService -Url "https://<SPO tenant name>-admin.sharepoint.com" -Interactive
Step 2b: Enable custom scripts on the target site
Run the following command to enable custom scripts on the site collection:
Set-SPOSite "https://<SPO tenant name>.sharepoint.com/sites/<Site name>" -DenyAddAndCustomizePages 0
- Replace <SPO tenant name> with your tenant name.
- Replace <Site name> with the site collection name (URL segment).
- The value 0 means custom scripts are allowed; 1 means they are blocked.
IMPORTANT: You must be a SharePoint Admin to run this command. Site Owner permissions are not sufficient.
Step 3 — Enable Custom Scripts via PnP PowerShell
Alternatively, you can use PnP PowerShell to enable custom scripts. This approach connects directly to the site URL and requires a registered Entra ID Application with appropriate permissions.
Step 3a: Connect to the target site via PnP PowerShell
Run the following command to connect to the site collection:
Connect-PnPOnline -Url "https://<SPO tenant name>.sharepoint.com/sites/<Site name>" -Interactive -ClientId <client id of your Entra ID Application Registration>
- Replace <SPO tenant name> with your tenant name.
- Replace <Site name> with the target site's URL segment.
- Replace <client id of your Entra ID Application Registration> with the Application (client) ID from your Microsoft Entra ID app registration.
Step 3b: Enable custom scripts on the tenant site
Run the following command to allow custom scripts:
Set-PnPTenantSite -Identity "https://<SPO tenant name>.sharepoint.com/sites/<Site name>" -DenyAddAndCustomizePages:$false
Note: Setting -DenyAddAndCustomizePages:$false enables custom scripts; use $true to block them again.
Result: Custom Scripts Enabled for Teamsware Studio
- The tenant-level Baseline Security Mode policy no longer blocks custom scripts across all SharePoint sites.
- The target site collection has custom scripts enabled (DenyAddAndCustomizePages = 0).
- Teamsware Studio can now create and update solutions on that site collection.
- The Solution Studio scripting capability dialog will no longer block solution creation on this site.
Additional Hints & Special Cases
24-Hour Reset Behavior
Per-site custom script changes are temporary by default. Any change that allows custom scripts on a specific site is automatically reset to Not allowed within 24 hours — unless the Baseline Security Mode policy is disabled at the tenant level first.
- Always verify the Baseline Security Mode setting is off before applying per-site overrides.
Permissions Required
Dialog Prompt in Solution Studio
When creating a new Teamsware solution on a site collection where custom scripts are disabled, Solution Studio will display a dialog prompting you to enable scripting capabilities. You can simply click the "Enable" button. After disabling the Baseline Security Mode Policy Teamsware Studio should be able to enable scripts for a specific site.
Further Reading