When attempting to run a PowerShell script you may receive the following error:
cdk.ps1 cannot be loaded because running scripts is disabled on this system.
For more information, see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170
This post is here to help you resolve this issue. The reason this is happening is due to the default ExecutionPolicy not allowing this action. We need to change it from Undefined to RemoteSigned or Unrestricted.
Resolution: Set Execution Policy to RemoteSigned
To resolve this “script cannot be loaded because running scripts is disabled on this system” error message:
1. Open PowerShell as Administrator.
2. Check current Execution Policies: Run Get-ExecutionPolicy
3. Amend Local Execution Policy: Run Set-ExecutionPolicy.
Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy RemoteSigned
All should work fine after the above.
Last updated: 29/09/2022