PowerShell Error Repair: Script execution is disabled on this system

Script execution is disabled on this system

PowerShell is an automation mechanism that helps users automate their tasks. Recently, many users have reported problems running a script in PowerShell.

According to user reports, in this case, the system displays the following error message.

Testscript.ps1 cannot be loaded because script execution is disabled on this system.

The error is mainly related to the security measures implemented in the Windows operating system. The system does not allow running scripts on your system without administrator rights. To fix the “Running scripts are disabled on this system” error, you must follow the steps listed in this article.

PowerShell, what is it?

PowerShell, what is it

PowerShell is a great Windows system management tool created by Microsoft. You can use command lines to automate your operating system.

It is a new tool that comes with Windows 10 and has many features. However, there are a few problems with these features.

Many users have encountered the error message “Running scripts is disabled on this system.”

As a result, the PowerShell runtime policy does not allow scripts to run. In addition, the same error is displayed when trying to run a PowerShell script.

This is a serious problem that makes PowerShell unusable. Fortunately, there are solutions and today we will show you what to do when you get the “Running scripts is disabled on this system” error in PowerShell.

If you know how to write simple PowerShell or batch scripts, you can automate many things in Windows 10. In fact, even if you have to spend some time writing the perfect script for something, once it works well, the time you save will be worth the time you spent writing the script. However, scripts can be dangerous. If you try to run scripts in PowerShell, you will get a rather long error message that basically says, “Scripting is disabled on this system.”

This is a security measure in PowerShell to prevent malicious scripts from running and potentially damaging the system. Of course, the script you wrote yourself is not malicious and should be capable of execution. To solve this problem, you need to change the execution policy in PowerShell.

What causes the “Running scripts is disabled on this system” error?

What causes the error

After receiving many reports from several users, we decided to investigate this issue and our research showed that the error is related to the following problem.

Powershell has built-in security features. One of them is the so-called enforcement policy.
This policy can prevent scripts from running and can be useful in certain situations.
For example, in high-security environments where it may be risky to run unknown Powershell scripts.
To view the current system-wide execution policy, type the following in Powershell :
Get-ExecutionPolicy

Before you focus on the framework, it’s helpful to know your options. This will help you avoid using risky or dangerous settings. You can choose from 4 levels of policy. From most secure to least secure:

  • Restricted: no PowerShell scripts can be executed. This is the default setting.
  • AllSigned: Scripts can be executed, but they must all be digitally signed. Even if you wrote the script yourself on the local computer.
  • DeletedSigned: Locally written scripts can be executed. But scripts coming from outside (email, instant messaging, Internet) must be signed by a trusted editor.
  • Unrestricted: Any script can be executed. It doesn’t matter who created them or if they are signed.

For the fix, I assume you downloaded the script. That’s why I suggest the “no limit” option in each solution. However, if you wrote the script yourself on your current PC, it is better to use RemoteSigned.

Now that you have a basic understanding of the nature of the problem, let’s move on to the solution.

The solutions for running scripts are disabled on this system

Solution 1: Add code

If you want to run a particular script on your computer without bothering to change the execution policy, you can always add some code to the command that gives access to the script via policy. To do this, you can do the following:

1.) Press “Windows” + “R” to open a runtime prompt.
2.) Type “Powershell” and simultaneously press “Shift” + “Ctrl” + “Enter” to allow administrative access.
3.) Enter a command to execute a specific script, such as the following command.
c:\> PowerShell -ExecutionPolicy ByPass -File script.ps1
4.) Press “Enter” and check if the problem persists.

Solution 2: Change the execution policy

Since the execution policy allows Powershell access to run a specific script, it blocks the execution of all scripts when they are defined as “restricted”.
You can set the policy in several modes depending on your situation. These modes are :

Restricted: In this mode, no scripts can be executed on the computer.
All Signed: If you choose this mode, only fonts signed by a trusted publisher can be run on the computer.
RemoteSigned: All downloaded scripts must be signed by a trusted publisher.
Unrestricted: There are no restrictions on scripts.

Now that you know which levels you can set the execution policy at, you can easily choose the one that best suits your needs. Change the execution policy:

1.) Press “Windows” + “R” to open a runtime prompt.
2.) Type “Powershell” and simultaneously press “Shift” + “Ctrl” + “Enter” to allow administrative access.
3.) Type the following command and press “Enter” to execute it.
Set-ExecutionPolicy Remotesigned
Note: Replace the word “RemoteSigned” with the desired security level as shown above.
4.) Press “Y” to specify “Yes.” This will change the group policy to the desired level.

Change the execution policy
5.) Check to see if the problem remains.

Frequently Asked Questions

  1. Open Start.
  2. Locate PowerShell, right-click on the highest result, then select Run as administrator.
  3. Enter the following command to allow the script to run, and press Enter: Set-ExecutionPolicy RemoteSigned.
  4. Enter A and press Enter (if applicable).

Solution: The default PowerShell Execution Policy is "Restricted". You can change the PowerShell Execution Policy using the Set-ExecutionPolicy command. To run a script remotely, set the policy to RemoteSigned.

  1. Open Internet Explorer.
  2. Click or tap the Tools button. Then click or tap the Manage add-ons button.
  3. Under View, click or tap All Add-ons, then select the add-on you want to disable.
  4. If you have ten add-ons installed, try disabling five at once and then fix the problem by logging in.

Go to the Start menu and look for "Windows PowerShell ISE". Right-click on the x86 version and select "Run as administrator". At the top, add Set-ExecutionPolicy RemoteSigned; run the script. Select Yes.