PowerShell’s execution policy is a safety feature that controls the conditions under which PowerShell loads configuration files and runs scripts. This feature helps prevent the execution of malicious scripts.
On a Windows computer you can set an execution policy for the local computer, for the current user, or for a particular session. You can also use a Group Policy setting to set execution policies for computers and users.
Execution policies for the local computer and current user are stored in the registry. You don’t need to set execution policies in your PowerShell profile. The execution policy for a particular session is stored only in memory and is lost when the session is closed.
The execution policy isn’t a security system that restricts user actions. For example, users can easily bypass a policy by typing the script contents at the command line when they cannot run a script. Instead, the execution policy helps users to set basic rules and prevents them from violating them unintentionally.
You can set an execution policy that is effective only in a particular scope.
The valid values for¬†Scope¬†are¬†MachinePolicy,¬†UserPolicy,¬†Process,¬†CurrentUser, and¬†LocalMachine.¬†LocalMachine¬†is the default when setting an execution policy.
The¬†Scope¬†values are listed in precedence order. The policy that takes precedence is effective in the current session, even if a more restrictive policy was set at a lower level of precedence.
If you set the execution policy for the scopes¬†LocalMachine¬†or the¬†CurrentUser, the change is saved in the registry and remains effective until you change it again.
If you set the execution policy for the¬†Process¬†scope, it’s not saved in the registry. The execution policy is retained until the current process and any child processes are closed.
This tutorial will show you different ways on how to set the PowerShell script execution policy for the current user, local machine, or current process in Windows 11.