PS1 cannot be loaded because running scripts is disabled on this system

Encountering the error message “PS1 cannot be loaded because running scripts is disabled on this system” in PowerShell can be a roadblock in your scripting or development. It’s a common error in PowerShell while attempting to run a command.

This post aims to guide you through resolving this issue, shedding light on the root cause and providing actionable solutions.

Understanding the “running scripts is disabled” Error in PowerShell

cdk.ps1 cannot be loaded because running scripts is disabled on this system. 
For more information, see about_Execution_Policies at

This common error stems from the default ExecutionPolicy, which restricts script execution for security reasons. To overcome this obstacle, we need to adjust the policy to allow the desired script to run.

Resolving the Issue

Set Execution Policy to RemoteSigned

Open PowerShell as Administrator and run the following command to set the local execution policy to RemoteSigned.

# Set local execution policy to remote signed
Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy RemoteSigned

# Check execution policy
PowerShell Get Local Execution Policy

This approach ensures scripts, both local and downloaded, signed by trusted publishers can run, maintaining a secure yet flexible environment.

Alternate Quick Fixes

If a quick, session-based solution is needed, consider the following options:

Bypass for Current Session

# Bypass execution policy for current session
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
PowerShell Set Execution Policy ByPass

This allows bypassing security checks for the current PowerShell session only.

Last Resort – Unrestricted:

# Set execution policy to unrestricted
Set-ExecutionPolicy Unrestricted

Be cautious with this option as it opens up your system to all script executions, not recommended for production environments.

Understanding Execution Policy Scope

Use the following command to view the current Execution Policies and their scopes:

# Get execution policy list for computer
Get-ExecutionPolicy -List

The output provides insights into the policies at different scopes:

  • MachinePolicy: Undefined
  • UserPolicy: Undefined
  • Process: Bypass (for the current session)
  • CurrentUser: Undefined
  • LocalMachine: Unrestricted

In some cases, the persistence of the issue may relate to the execution policy scope, which can be configured differently for the current user or local machine. Ensure to check the scope if the problem persists after making policy changes.

With the appropriate execution policy in place, executing your .ps1 scripts should no longer be hindered by the “PS1 cannot be loaded” error. Feel free to reach out if you have any further questions.

Leave a Reply

Your email address will not be published. Required fields are marked *