PowerShell: Runnig scripts is disabled (Execution Policies)

Petr Kostelanský | 12 March 2019
When you try to run Powershell script for the first time you will get an error because default execution policy for Windows is to not run Powershell scripts and we have to change this policy before.

The easiest way how to fix error "cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies" is to run this before you run your Powershell script:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

So, what's going on here. At first, we set the -Scope parameter with Process. We are saying that this set of execution policy is just for this process and in the next session, we get the error again. The -ExecutionPolicy parameter with value Bypass means that nothing is blocked.

But maybe we want to be able to run scripts forever and we can do that by execution:

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass 

So, we have unblocked all scripts running by this user.


Of course, there are different ways how we can set Execution policy and I can recommend you Microsoft doc About Execution Policies for more details.


Loading ads...