Solve: PowerShell Says running scripts is disabled on this system

While running a script in your Windows 11 or 10 PowerShell you may encounter an error that says the script execution is disabled on your system. It is a security feature, not some system problem that is meant to prevent the automatic execution of scripts, which could potentially be harmful. However, what if you need to run scripts to complete some task, well, in that case, a user has to enable the script execution in PowerShell.

In this tutorial, we learn the command that lets you enable PowerShell script execution, here are the steps to follow:

1. Open PowerShell as an Administrator:

Ofcourse, we need the PowerShell access. To open it you can either right-click on the Windows Start button to select Terminal (Admin) / PowerShell(Admin) or search for it in the Start menu search box and select “Run as administrator.

Open PowerShell

2. Check Current Execution Policy:

Well, let’s first check and confirm what the current execution policy is set for any script to run in PowerShell. For that run the given command. If the output says “Restricted” that means by default your system does not allow running scripts in PowerShell.

Get-ExecutionPolicy

3. Change the Execution Policy to run scripts:

If the current execution policy is set to “Restricted,” we need to change it to some less restrictive one, so that we can execute the scripts. For that, we can set the PowerShell execution policy to “RemoteSigned“. It will tell the system to run the local script but requires remote scripts to be signed by a trusted publisher so that we won’t compromise our security.

Set-ExecutionPolicy RemoteSigned

If prompted to confirm the change, type ‘Y’ and press Enter.

PowerShell running scripts is disabled

4. Restart PowerShell:

Although it is not required, yet, to make sure the changes we made to the execution policy are applied correctly, close and reopen the PowerShell.

Now, again check the current policy using:

Get-ExecutionPolicy

This time you will see a “RemotelySigned” value instead of “Restricted”.

5. Reset Execution Policy (Optional):

Those who later want to set their PowerShell execution policy back to what it was set by default i.e “Restricted” can use the given command

Set-ExecutionPolicy Restricted

Choose a policy that aligns with your security preferences. You can learn more about it and other available policies on the official Microsoft learning website.

By default, the execution policy is set to “Restricted” for security reasons. So, make sure you are changing it to work with some trusted scripts without jeopardizing your system security.

Other Articles: