While trying to add a new value to the site’s property bag, I received the following error.
Access denied. You do not have permission to perform this action or access this resource. Site might have NoScript enabled, this prevents setting some property bag values.
This error occurs when scripting is disabled on the site. If scripting is off, we’re not allowed to modify property bag values as well. To overcome this, we can temporarily enable scripting on the site to perform our action. Once we’re done, we can then again disabled the scripting setting, if required.
Connect-SPOService -Url <TenantAdminUrl> Set-SPOsite <SiteURL> -DenyAddAndCustomizePages 0
Similarly, we can disable scripting on the given site as well.
Connect-SPOService -Url <TenantAdminUrl> #Need to be connected only once during a single online session Set-SPOsite <SiteURL> -DenyAddAndCustomizePages 1
- SharePoint modern sites require us to disable scripting on the site.
- So, if we need to update property bag values, we can temporarily enable scripting, do our job, and then revert back to the original setting.
- To run this cmdlet, you need to have SharePoint Online Management Shell installed on your local machine.
- Please note that, enabling scripting on a site has multiple implications and is not merely limited to updating property bag values. For a full list of features affected by this setting, please visit this link.