In this article, we will discuss “How to set the PowerShell Execution Policy via Windows Registry”. PowerShell is a cross-platform task automation and configuration management framework, consisting of a command-line shell and scripting language. Please see Determine the execution policy configured on Windows PC, and How to install and update PowerShell version 7 on Windows and Linux.
Unlike most shells, which accept and return text, PowerShell is built on top of the .NET Common Language Runtime (CLR), and accepts and returns. NET objects. PowerShell is configured to prevent the execution of PowerShell scripts on Windows systems by default.
To run commands, one of the following systems must be taken into consideration.
HKEY_CURRENT_USER\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
Set the string value ExecutionPolicy to one of the following values:
- Restricted
- AllSigned
- RemoteSigned
- Unrestricted and
- Undefined.
To change the execution policy for the LocalMachine scope, Navigate to the path as shown below.
Currently, no value is set and none is currently available. To set the string value ExecutionPolicy to one of the following values:
Moreover, Create a new string and enter any ExecutionPolicy value you desire as below. Restricted, AllSigned, RemoteSigned, Unrestricted, Undefined.
Nonetheless, Create a new string and name it ExecutionPolicy. Now enter the desired value.
Press okay afterwards and that is all. Please see how to Mitigate Windows Print Spooler Remote Code Execution Vulnerability.
FAQs on PowerShell Execution Policy
You can bypass the execution policy for a specific script by adding the -ExecutionPolicy Bypass
parameter when running the script in the PowerShell command line.
To change the PowerShell execution policy, open PowerShell as an administrator and use the Set-ExecutionPolicy cmdlet followed by the desired policy, such as RemoteSigned or Unrestricted.
The default execution policy is typically set to Restricted. You can check the current execution policy by running the command Get-ExecutionPolicy in a PowerShell window.
Changes to the execution policy can be made permanently using the Set-ExecutionPolicy cmdlet with the -Scope parameter set to MachinePolicy. This ensures that the policy is applied globally and persists across sessions.
Furthermore, I hope you found this blog post on How to set the PowerShell Execution Policy via Windows Registry helpful. However, please let me know in the comment session if you have any questions.