PowerShell is a powerful scripting language and automation tool that comes built-in with Windows operating systems. It allows users to automate tasks, manage system configurations, and interact with various services. However, when running PowerShell scripts, you may encounter the error “Running scripts is disabled on this system”. This error occurs due to PowerShell’s default execution policy, which is set to Restricted, preventing any scripts from being executed to enhance system security.

Advertisement

In this article, we will explore the different execution policies in PowerShell and guide you through the process of resolving this error to enable script execution.

Understanding PowerShell Execution Policies:

PowerShell features four primary execution policies that determine the conditions under which scripts can be executed:

  • Restricted: This is the default policy and prevents running any scripts. You can still use PowerShell for individual commands but cannot execute scripts.
  • AllSigned: This policy allows you to run scripts that have been digitally signed by a trusted publisher. Any unsigned scripts will not be executed.
  • RemoteSigned: This policy enables you to run locally-created scripts, while scripts downloaded from the internet must be signed by a trusted publisher to execute.
  • Unrestricted: This policy permits the execution of all scripts, regardless of their origin or whether they are signed. This setting may pose security risks, so use it with caution.

Error:

This error comes when the PowerShell execution policy doesn’t allow us to run scripts. I also found the same error when tried to run a PowerShell script.

PowerShell – Running scripts is disabled on this system
PowerShell Error– Running scripts is disabled on this system

Solution:

To resolve the “Running scripts is disabled on this system” error, you need to change the execution policy. Follow these steps:

  1. Launch PowerShell with administrative privileges: Click on the Start menu, type “PowerShell”, right-click on “Windows PowerShell,” and select “Run as administrator”.
  2. Check the current execution policy: To verify the current policy, run the following command:

  3. Change the execution policy: To change the policy, use the `Set-ExecutionPolicy` cmdlet, followed by the desired policy. For example, to set the execution policy to RemoteSigned, run:

    You will be prompted to confirm the change. Press “Y” and then Enter to confirm.

  4. Verify the new policy: Run `Get-ExecutionPolicy` again to ensure that the policy has been changed successfully.
  5. Close and reopen the PowerShell window to apply the changes.

Note: It is essential to understand the security implications of changing the execution policy. Be cautious when selecting a policy, as it may expose your system to potential risks. The RemoteSigned policy is a good balance between security and functionality for most users.

Conclusion:

In this article, we have explored PowerShell execution policies and provided a step-by-step guide on resolving the “Running scripts is disabled on this system” error. By changing the execution policy, you can enable the running of PowerShell scripts on your system while still maintaining an appropriate level of security. Remember to exercise caution when choosing an execution policy and always run scripts from trusted sources to protect your system from potential threats. With the error resolved, you can now harness the full power of PowerShell scripts to automate tasks and manage your system more efficiently.

Share.

18 Comments

  1. Thanks for the tutorial
    I tried to write the command and the response was:
    ‘Set-ExecutionPolicy’ is not recognized as an internal or external command,
    executable program or batch file.

  2. Mine didn’t work. This is the error

    Get-Process : A positional parameter cannot be found that accepts argument ‘Set-ExecutionPolicy’.
    At line:1 char:1
    + PS C:\> Set-ExecutionPolicy RemoteSigned
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Get-Process], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetProcessCommand

  3. Rajkumar Pandey on

    Hi,RAHUL

    Thank You So Much For PowerShell – Running scripts is disabled on this system. You Explanation is good.

Leave A Reply


Exit mobile version