Fix: ‘Running Scripts is Disabled on this System’ Error on Powershell
Powershell is a task automation and management framework that has been developed and published by Microsoft. It consists of a command-line shell and an associated language. Users can execute numerous cmdlets in the program. However, quite recently, a lot of reports have been coming in where users are unable to run a script and the “Running Script is Disabled on this System” or the “execution of scripts is disabled on this system” error shows up in the Powershell.
In this article, we will discuss the reason due to which this error might be triggered and some viable solutions to fix it permanently. Make sure to follow the steps carefully and accurately to avoid conflict.
What Causes the “Running Scripts is Disabled on this System” Error?
After receiving numerous reports from multiple users, we decided to look into the matter and our research suggests that the error is caused due to the following problem.
- Disabled Scripts: Every Script that you run on the Powershell must have some level of verification from trusted sources in order for it to work. However, in some cases, even if the script does have verification it is still stopped from execution because of restricted access. The thing is that Windows has an “Execution Policy” that the script needs to bypass in order for it to be executed. If the Execution Policy is set to “Restricted” then no script can be run on the computer.
Now that you have a basic understanding of the nature of the problem, we will move on towards the solutions.
Solution 1: Adding Code
If you want to run a particular script on your computer without going through the hassle of changing the execution policy, you can always add a piece of code to the command which will grant the script access through the policy. For that:
- Press “Windows” + “R” to open the run prompt.
- Type in “Powershell” and press “Shift” + “Ctrl” + “Enter” simultaneously to grant administrative access.
- Type in the command to execute a particular script like the following command.
c:\> powershell -ExecutionPolicy ByPass -File script.ps1
- Press “Enter” and check to see if the issue persists.
Solution 2: Changing the Execution Policy
Since the execution policy provides access to the Powershell to run a particular script, if it is set to restricted, it will block all scripts from being executed. There are different modes that you can set the policy to depending upon your situation. Those modes are:
- Restricted: This mode doesn’t allow any script to be run on the computer.
- AllSigned: By choosing this mode, only the policies that are signed by a trusted publisher can be run on the computer.
- RemoteSigned: All downloaded Scripts must be signed by a trusted publisher.
- Unrestricted: There is no restriction on any script at all.
Now that you know the levels to which the execution policy can be set to, you can easily choose the best one for you depending upon your requirements. In order to change the execution policy:
- Press “Windows” + “R” to open the run prompt.
- Type in “Powershell” and press “Shift” + “Ctrl” + “Enter” simultaneously to grant administrative access.
- Type in the following command and press “Enter” to execute it.
Set-ExecutionPolicy Remotesigned
Note: The word “RemoteSigned” is to be replaced with the security level that you want as indicated above.
- Press “Y” to indicate Yes and this will change the Group Policy to the desired Level.
- Check to see if the issue persists.