Table of Contents

Maintaining custom scripts in PWA

There are scenarios where features in legacy products run into issues caused by a new security setting introduced by Microsoft that prevents javascript from running in a SharePoint site.

You can manually change this setting from your SharePoint Administrative Portal -> Sites -> Active Sites -> Site -> Settings:

Image shows UI for CustomScriptsSetting

Changing this setting can alleviate problems with javascript based solutions such as PGI or Script Pack webparts, however Microsoft has announced they will be automatically changing the value of this setting back to disable scripts every 24 hours.

From Microsoft:

"Please be aware that the new PowerShell command will only be accessible until mid-November 2024 (previously May). Post that period, on SharePoint sites if administrators wish to continue using features that are only available when unmanaged custom scripts are permitted to run, they will need to re-enable the running of custom scripts every 24 hours."

As this functionality is required for the continued operation of production software, we have provided a Power Automate Flow that is capable returning this setting back to enabled state.

Please find the flow downloadable here.

This PowerAutomate flow requires a connection to be created prior to import:

Image shows UI for Flow connection

This connection must

  • Be using credentials that have access to the SharePoint Administrative portal
  • Be set to target the SharePoint administrative portal which has a URL usually in the format https://tenantName-admin.sharepoint.com

After importing the Flow:

  1. Set the variable for the PWA URL target
  2. Test the Flow
  3. Replace the trigger with a schedule trigger to ensure this setting is correct as required.