How to Fix: PowerShell 'Running Scripts is Disabled on This System' Error
In this tutorial, I will show you how to fix the Running Scripts is Disabled on This System
error in PowerShell.
This error is caused by the PowerShell execution policy. You can check the current policy by running the following command:
Get-ExecutionPolicy
If the policy is set to something like Restricted
or AllSigned
, you won’t be able to run scripts.
Change the Execution Policy to Allow Scripts
The solution is to change the execution policy to one that allows scripts to run, using the Set-ExecutionPolicy
command.
There are a couple of execution policies that allow running scripts. One is RemoteSigned
. If you set the execution policy to RemoteSigned
, you can run scripts you create locally. However, you won't be able to run scripts downloaded from the internet unless they're signed by a trusted publisher.
To set the execution policy to RemoteSigned
, run the following command:
Set-ExecutionPolicy RemoteSigned CurrentUser
The other option is Bypass
, which allows all scripts to run without any restrictions. You can set execution policy to Bypass
by running the following command:
Set-ExecutionPolicy Bypass CurrentUser
If you set the execution policy to Bypass
, you’ll be able to run any scripts without getting the error: Script cannot be loaded because running scripts is disabled on this system
.
There’s more to the execution policy than what we've covered here. If you'd like to learn more about PowerShell execution policies, click the link below.
PowerShell Execution Policy: How to Set and Use It