PowerShell running scripts is disabled on this system | Error resolved

PowerShell is a scripting language with a command-line interface developed by Microsoft. It is used to run a script on the Windows Operating System. A PowerShell script comprises several PowerShell commands which are executed in a sequence.

If you are new to PowerShell and running the script for the first time, an error “running scripts is disabled on this system” is thrown by the PowerShell. This error refers to the execution policy of the machine which is restricted by default. This post demonstrates various methods to resolve the PowerShell “running script is disabled on the system” error. The outcomes of this article would be;

  • What does “running scripts is disabled on a local machine” mean?
  • How to solve the “running scripts is disabled on a local machine” error?

What does “running script is disabled on a local machine” mean?

If you are executing PowerShell’s scripts for the first time, an error is shown in the console window. The interpretation of this error is that the execution policy of PowerShell is restricted by default. It does give permission to run the script.

In the above figure, test.ps1 is executed in PowerShell ISE. It shows an error: the script is not loaded because the configuration in PowerShell is restricted for safety features. Moreover, the execution policy of PowerShell is used to avoid malicious activities during the run of the script in PowerShell.

To resolve the error in PowerShell, there are different ways. The upcoming section provides a detailed solution to get rid of the running script error.

How to solve the “running script is disabled on this system” error?

Here, we will provide all the possible methods to enable the PowerShell execution scripts. To counter the error, you can set the execution policy to RemoteSigned or to Unrestricted. Furtherly, you can also bypass the default execution policy to run the scripts.

The RemoteSigned execution policy is a safe policy. The policy makes sure the script must be signed if the script was created on its own. The Unrestricted policy enables the user to run the script without any restriction. The Bypass value ignores all the security checks and prompt messages(it can be harmful to execute any malicious script).

Let’s get into the above-stated methods.

Method 1: Use the RemoteSigned execution policy

One of the most secure options to resolve the error is the RemoteSigned execution policy. It enables the user to run the local script, while other scripts require permission from the publisher.

The following command will change the current execution policy and will set it to RemoteSigned.

Note: Run the PowerShell as an administrator to execute this command.

 Set-ExecutionPolicy RemoteSigned

After that, there is a pop-out window on which you press the button Yes to All to change the execution policy.

By pressing the button, the execution policy is updated successfully. You can verify it by checking the current execution policy of your machine via the Get-ExecutionPolicy cmdlet as follows.

Get-ExecutionPolicy

It is observed from the output that the execution policy is set to RemoteSigned.

Method 2: Use the Unrestricted execution policy

To enable the unrestricted execution policy, PowerShell provides a policy named “Unrestricted“. This execution policy also helps to solve the “running script is disabled on the system” error.

The following command will change the execution policy to Unrestricted:

Set-ExecutionPolicy Unrestricted

The above code warns the administrator of the policy change.

The pop-out window shows different buttons. Select the Yes to All button to update the execution policy in PowerShell.

To verify the change, check the current execution policy by using the following command:

Get-ExecutionPolicy

Method 3: Bypass the execution Policy

In PowerShell, there is another method to resolve the execution error of the scripts. Basically, the Bypass value is passed to the -executionpolicy parameter. This value suppresses the effect of the Execution Policy.

For instance, a PowerShell script (Titles.ps1) is being executed with the Bypass value of the -executionpolicy parameter:

powershell -executionpolicy ByPass -File E:\alias.ps1

After execution of the command, the restriction policy is bypassed and allows the script to execute in the current session.

In this post, You have learned to get rid of the script execution error.

Conclusion

In this post, the running script which is disabled in PowerShell is resolved by changing the execution policy of the machine to Remotesigned and Unrestricted. Apart from these, one can bypass the execution policy effect on the script to resolve the “running script is disabled on the system” error. The default execution policy of the machine is set to “restricted” which does not support an unauthentic operation via PowerShell.



from https://ift.tt/eQnkYyU

Post a Comment

0 Comments