Set-PnpPropertyBagValue

Site might have NoScript enabled

Premise

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.

Solution

Set-PnpPropertyBagValue

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.

Enable Scripting

Connect-SPOService -Url <TenantAdminUrl>
Set-SPOsite <SiteURL> -DenyAddAndCustomizePages 0

Similarly, we can disable scripting on the given site as well.

Disable Scripting

Connect-SPOService -Url <TenantAdminUrl> #Need to be connected only once during a single online session
Set-SPOsite <SiteURL> -DenyAddAndCustomizePages 1

Key Takeaways

  • 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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.