Fix for PowerShell Script cannot be loaded because running scripts is disabled on this system error

Problem: Getting “cannot be loaded because running scripts is disabled on this system” error!

On trying to run a PowerShell script from the PowerShell console, I received this error message: “File C:\temp\GenerateRpt.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. At line:1 char:1 CategoryInfo: SecurityError PSSecurityException FullyQualifiedErrorId : UnauthorizedAccess”

cannot be loaded because running scripts is disabled on this system

In some cases, You’ll see the following error message, “The file is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies.”.

File C:\Temp\Backup.ps1 cannot be loaded. The file C:\Temp\Backup.ps1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.

Root Cause:

This is due to the Windows PowerShell execution policy being set to prevent untrusted scripts that can affect your Windows client environment. Execution policies are security settings that determine the trust level for scripts run in PowerShell. The default execution policy is “strict” on client operating systems like Windows 10 PC, preventing Windows PowerShell commands and scripts from running.

Solution for “cannot be loaded because running scripts is disabled on this system”

How do you enable PowerShell scripting and resolve running scripts is disabled on this system error? To fix this issue, we have to set the execution policy using the Set-ExecutionPolicy cmdlet, so that the PowerShell script runs on the particular machine. Here is how to permit PowerShell script execution:

Step 1: Check the current Execution Policy

Open the PowerShell Console by selecting “Run as Administrator” (Or Right-click the Start menu and choose “Windows PowerShell (Admin)” from the context menu) and get the execution Policy with the command:

Get-ExecutionPolicy

PowerShell Run as Administrator

This will get the current script execution policy applied, such as “Restricted”.

Step 2: Set the Execution Policy

Set the execution Policy with the following command:

Set-ExecutionPolicy RemoteSigned

You’ll see a security risk warning. Type “Y” or “A” when prompted to proceed. That’s all! This should solve the issue.

Fix for PowerShell Script cannot be loaded because running scripts is disabled on this system error

You can also use Set-ExecutionPolicy Unrestricted to remove all restrictions on your security policy (However, the RemoteSigned execution policy is ideal among different modes!). Once you have changed the execution policy, you should be able to run scripts without encountering the “running scripts is disabled on this system” error.

The RemoteSigned policy requires a trusted publisher to sign scripts and configuration files from the internet. Any unsigned scripts downloaded will be blocked, but the execution of scripts created locally is permitted without any digital signature.

Behind the scenes, it sets the registry key: HKLM\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell. You can also make the policy change through the Registry Editor to set the execution policy (Open Registry Editor from the search box on the taskbar >> Navigate to the below path and update the value data of “ExecutionPolicy”).

execution policy in windows registry editor

The policy parameter takes the below values:

  • Restricted – No scripting allowed
  • Unrestricted – You can run any script, No signing is required.
  • RemoteSigned – Good for Test and dev environments. Only files from the internet need to be signed. Otherwise, you’ll see .ps1 is not digitally signed error. This is the default policy setting on servers. More secure option compared with unrestricted.
  • AllSigned  – local or remote script – A trusted publisher should sign it; only digitally signed PowerShell scripts are allowed.

What if you can’t set the Execution Policy by running PowerShell as Administrator?

To set the execution policy for the current user scope, use the following:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

The default scope is “LocalMachine”, which sets the policy for all users of the current machine. You can get the execution policy for all scopes using:

Get-ExecutionPolicy -List

Output:

PS C:\>
        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine    RemoteSigned

Bypass ExecutionPolicy Temporarily for a Session

How to bypass the PowerShell execution policy? To bypass the execution policy just for a one-time session, in the command prompt, type:

PowerShell -ExecutionPolicy Bypass

Once you close the PowerShell window, the current PowerShell session ends, and the Bypass is also closed with it. This allows you to run a PowerShell script file temporarily while keeping the ExecutionPolicy settings for all other PowerShell sessions. You can also unblock the file from its properties or copy-paste the script contents into the PowerShell console to bypass the execution policy.

How about bypassing the execution policy and running the script in PowerShell ISE?

You can bypass the execution policy by selecting a block of the script and then hitting F8 (Run Selection).

running scripts is disabled on this system

Use Group Policy Object to Set Execution Policy for Multiple Computers

If you want to change the execution policy on multiple computers, you can use Group Policy in your Domain controller. Here is how to enable running scripts is disabled on this system:

  1. Open the Group Policy Editor.
  2. Under “Local Computer Policy” navigate to Computer Configuration >> Administrative Templates >> Windows Components >> Windows PowerShell
  3. Enable the “Turn on Script Execution” policy, Then select the desired execution policy from the drop-down list, such as “Allow local scripts and remote signed scripts”, which is equivalent to the “RemoteSigned” property we set using Set-ExecutionPolicy command.
    Fix Running Scripts is Disabled on this System Error in PowerShell

Here is the Microsoft reference: Configure execution policies

Wrapping up

The “running scripts is disabled on this system” error in PowerShell can be frustrating, but it is easily fixed by changing the execution policy. By understanding execution policies and following the steps outlined in this article, you can enable script execution and take advantage of PowerShell’s powerful automation capabilities.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

46 thoughts on “Fix for PowerShell Script cannot be loaded because running scripts is disabled on this system error

  • thanks a million

    Reply
  • thank u so much

    Reply
  • Thanks. This solved my problem. God Bless.!

    Reply
  • Thank you very much for this article, helped me work out a big problem I was having with one of my scripts.

    Reply
  • Thanks you actually solved my issue in few seconds, now scripts are running in powershell in vscode

    Reply
  • It worked for me! Great guide to fix Script cannot be loaded because running scripts is disabled on this system error. Thank you!

    Reply
  • Thank you so much, it really helped!

    Reply
  • Thanks, That actually helped

    Reply
  • thank you ( rahmat )

    Reply
  • I found it very helpfull.The step-by-step instructions provided are easy to follow and allowed me to quickly resolve the issue. Overall, it’s a great resource for anyone who needs to enable script running in PowerShell and is experiencing this error.

    Reply
  • Thanks, works fine.

    I am getting an issue though where if I right-click the script and click ‘Run with PowerShell’, the script seems to execute regardless of execution policy.

    Is this expected behaviour?

    Reply
  • God bless! Worked like a charm.
    Neede for VScode to run nodemon, this fixed it, thanks

    Reply
  • Nice article, I don’t work with PS much, so this was very helpful.

    Reply
  • Thanks, its working

    Reply
  • This was easy answer. Thank you.

    Reply
  • Thanks for this article, though the registry is set to RemoteSigned I am still getting the error displayed, I cant figure out what I am doing wrong, any help would be greatly appreciated

    Reply
  • I appreciate your blog; it is helpful.

    Reply
  • thanks a lot, this helped me!

    Reply
  • Amazing. Thanks!

    Reply
  • Thank you very much Sir, I appreciate this.

    Reply
  • Thank you really worked the solution

    Reply
  • Thank you 🙂 It’s working

    Reply
  • thanks a lot. It worked.

    Reply
  • Thank you. It’s working.

    Reply
  • Thanks a lot. It helped me.

    Reply
  • That Actually Helped, Thanks a bunch, easy and smooth answer

    Reply

Leave a Reply

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