/commands/powershell/get-executionpolicy-list
Get-ExecutionPolicy -List: PowerShell execution policy scopes and which one wins
- tool
- PowerShell
- versions
- Windows PowerShell 5.1, PowerShell 7.x on Windows
- os
- windows
Get-ExecutionPolicy -List prints the execution policy set at each of the five scopes, in precedence order. The effective policy (what plain Get-ExecutionPolicy returns) is the first scope in that list that is not Undefined; if all are Undefined, the default applies: Restricted on Windows client editions, RemoteSigned on Windows Server.
Get-ExecutionPolicy -List
Get-ExecutionPolicy # effective policy
Get-ExecutionPolicy -Scope CurrentUserThe scopes
| Scope | Set by | Stored in |
|---|---|---|
| MachinePolicy | Group Policy (Computer Configuration) | registry policy key; cannot be changed with Set-ExecutionPolicy |
| UserPolicy | Group Policy (User Configuration) | registry policy key; cannot be changed with Set-ExecutionPolicy |
| Process | Set-ExecutionPolicy -Scope Process, or powershell -ExecutionPolicy X | $env:PSExecutionPolicyPreference; ends with the process |
| CurrentUser | Set-ExecutionPolicy -Scope CurrentUser (no admin needed) | HKEY_CURRENT_USER |
| LocalMachine | Set-ExecutionPolicy (default scope, needs admin) | HKEY_LOCAL_MACHINE |
See precedence at work
The block changes only the Process scope of its own PowerShell process:
(Get-ExecutionPolicy -List).Scope -join ' > '
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Restricted -Force
"Process scope: $(Get-ExecutionPolicy -Scope Process); effective: $(Get-ExecutionPolicy)"
Set-ExecutionPolicy -Scope Process -ExecutionPolicy AllSigned -Force
"Process scope: $(Get-ExecutionPolicy -Scope Process); effective: $(Get-ExecutionPolicy)"
"env var: $env:PSExecutionPolicyPreference"Output
MachinePolicy > UserPolicy > Process > CurrentUser > LocalMachine Process scope: Restricted; effective: Restricted Process scope: AllSigned; effective: AllSigned env var: AllSigned
Because Process comes before CurrentUser and LocalMachine, it overrides them; only the two Group Policy scopes override Process.
The policies
| Policy | Effect |
|---|---|
| Restricted | no script files run; interactive commands only (Windows client default) |
| AllSigned | every script must be signed by a trusted publisher |
| RemoteSigned | local scripts run; downloaded scripts (with the mark of the web) must be signed or unblocked (Windows Server default) |
| Unrestricted | all scripts run; downloaded ones ask for confirmation |
| Bypass | nothing is blocked and there are no warnings |
| Undefined | no policy at this scope |
If Set-ExecutionPolicy prints a warning that the setting is overridden by a policy defined at a more specific scope, a higher scope (often Group Policy) is set; Get-ExecutionPolicy -List shows which one.
Sources
- learn.microsoft.comlearn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-executionpolicy
- learn.microsoft.comlearn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies
- learn.microsoft.comlearn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy