PowerShell cannot be loaded because running scripts is disabled on this system windows 10

This PowerShell tutorial, we will discuss how to solve PowerShell cannot be loaded because the execution of scripts is disabled issue, which comes while running PowerShell cmdlets in Windows 10 machine.

Recently I was trying to run a PowerShell command using PowerShell ISE, but it gave an error:

cannot be loaded because running scripts is disabled on this system like below:

powershell cannot be loaded because the execution of scripts is disabled

PowerShell cannot be loaded because the execution of scripts is disabled

The error was coming because the PowerShell execution policy doesn’t allow to run scripts by default in the Windows 10 laptop.

By default, the PowerShell policy was set to Restricted which means No scripts can be executed.

To allow script execution, we need to use the Set-ExecutionPolicy PowerShell cmdlets. Run the cmdlet like below:

Set-ExecutionPolicy Unrestricted

It will show you a confirmation box, select Yes to All and then when you run any cmdlets in PowerShell, it will run successfully like below:

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

To run outside script set Set-ExecutionPolicy to RemoteSigned like:

Set-ExecutionPolicy RemoteSigned 

Below are the different types of policy we can set for PowerShell.

  • Restricted: You can run any script, no script is allowed to run.
  • Unrestricted: All Windows PowerShell scripts can be run.
  • AllSigned: Only trusted publisher scripts are allowed to run.
  • RemoteSigned: Downloaded scripts must be signed by a trusted publisher.

If you want to know what is current policy set, then you can run the below PowerShell cmdlets.

get-executionpolicy

You can bypass this policy by adding -ExecutionPolicy ByPass when running PowerShell

powershell -ExecutionPolicy ByPass -File myscript.ps1

If you wanted to change the policy to RemoteSigned/Unrestricted for just the CurrentUser, you can run the below PowerShell cmdlets.

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
or 
Set-ExecutionPolicy -Scope "CurrentUser" -ExecutionPolicy "Unrestricted"
or
Set-ExecutionPolicy -Scope "CurrentUser" -ExecutionPolicy "RemoteSigned"

You may like following PowerShell tutorials:

This PowerShell tutorial, we learned how to solve cannot be loaded because running scripts is disabled on this system error which comes in windows 10 while running PowerShell cmdlets.

>