trio.so
Explained

PowerShell Execution Policies Explained for IT Admins

What each PowerShell execution policy does, how to check and set it with Set-ExecutionPolicy, and how to fix "running scripts is disabled".

Mountain landscape representing leadership perspective and vision
Written by
Atena Ladchartabi

Content writer, trio.so

Published on
Modified on

A PowerShell execution policy is a Windows setting that decides whether PowerShell runs scripts, and under what conditions. There are six policy types (Restricted, AllSigned, RemoteSigned, Unrestricted, Bypass and Undefined) and five scopes, and Group Policy beats everything set locally. Check the current state with Get-ExecutionPolicy -List and change it with Set-ExecutionPolicy. If you see "running scripts is disabled on this system", the usual safe fix is Set-ExecutionPolicy RemoteSigned -Scope CurrentUser.

If that error is what brought you here, the fix is in the next section; if you set policy for a fleet, the scope, enforcement and compliance sections are for you.

TL;DR

  • PowerShell execution policy controls which scripts can run, but Microsoft says plainly that it is not a security boundary: anyone can bypass it.
  • Six policy types exist: Restricted, AllSigned, RemoteSigned, Unrestricted, Bypass and Undefined. RemoteSigned is the usual enterprise baseline.
  • Five scopes apply in precedence order: MachinePolicy (Group Policy) > UserPolicy (Group Policy) > Process > CurrentUser > LocalMachine. Group Policy always wins.
  • Use Get-ExecutionPolicy -List, not just Get-ExecutionPolicy, to see which scope controls the effective policy on a machine.
  • Setting the policy through Group Policy or MDM stops users from overriding it locally. Set-ExecutionPolicy alone does not.
  • Execution policy needs companions: Script Block Logging (Event ID 4104) and AMSI provide the controls that execution policy cannot.

How to fix "running scripts is disabled on this system"

The full error reads something like: File C:\scripts\setup.ps1 cannot be loaded because running scripts is disabled on this system. It means the effective execution policy on that PC is Restricted, which is the default for Windows client computers in Windows PowerShell 5.1. Restricted allows single commands but no script files.

Fix it for your own account, without admin rights and without opening the whole machine:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

RemoteSigned runs scripts you wrote locally and blocks unsigned scripts downloaded from the internet. If the script you need was downloaded and you trust it, unblock that one file instead of loosening the policy:

Unblock-File -Path .\setup.ps1

To run one script once without changing any setting, start a session with the policy for that session only:

powershell.exe -ExecutionPolicy Bypass -File .\setup.ps1

Avoid Set-ExecutionPolicy Unrestricted as a permanent fix. If the change does not take, run Get-ExecutionPolicy -List: a value at MachinePolicy or UserPolicy means Group Policy sets it, and only a Group Policy change will move it.

What PowerShell Execution Policy Actually Does (and Doesn't Do)

PowerShell execution policies are preference settings. They tell PowerShell whether to run scripts, and under what conditions. They are not a firewall, not an antivirus layer and not an access control mechanism. Microsoft's documentation is direct on this point: the execution policy isn't a security boundary, and users can bypass it by typing the script contents at the command line.

Its real purpose is to prevent accidental script execution: a double-click on a .ps1 file, or an unintended run from an Explorer context menu. That is a legitimate operational safeguard. It is also why some practitioners call it security theater, and that criticism is worth taking seriously. Execution policy works alongside other controls, and the enforcement method and the layered stack are what make the environment defensible. That is why this article covers more than the six policy types.

Two PowerShell engines are in common use: Windows PowerShell 5.1, which ships with Windows 10, Windows 11 and Windows Server, and PowerShell 7, which is cross-platform and installed side by side. They keep separate execution policy settings, so setting the policy in one engine has no effect on the other. Microsoft's PowerShell 7 documentation lists RemoteSigned as its default on Windows.

If you have ever set RemoteSigned and still had a script blocked, or set a policy that seemed to apply but did not stop anything, the answer is almost always in the scope chain, or in the fact that execution policy was never meant to catch an attack in the first place. Both topics are covered below.

The Six Policy Types and Five Scopes

Setting the execution policy correctly means understanding two separate things: the type (what behavior you want) and the scope (where it applies and who it affects). A RemoteSigned policy at the CurrentUser scope behaves very differently from the same policy enforced at MachinePolicy through Group Policy. The combination of type and scope determines the actual outcome on the machine.

The Six Policy Types

  • Restricted. No scripts run at all; individual commands only. This is the default for Windows client computers in Windows PowerShell 5.1. It suits endpoints with no scripting need, but it blocks all automation.
  • AllSigned. Every script, local and remote, must be signed by a trusted publisher. It needs a PKI to work across many machines and is the strictest scripting policy available. It has its own section below.
  • RemoteSigned. Scripts downloaded from the internet must be signed; scripts written locally run without a signature. It is the default for Windows Server and the standard enterprise baseline. "Remote" means the file carries a Zone.Identifier tag (the Mark of the Web), not simply that it sits on a network share.
  • Unrestricted. All scripts run; scripts from the internet prompt the user but are not blocked. Do not set it as a persistent policy on production machines.
  • Bypass. Nothing is blocked, with no warnings or prompts. It is designed for applications that run PowerShell inside their own security model. Tools that handle remote script execution often use Process-scope Bypass so each session manages its own context without leaving a persistent setting. Session-scoped use in controlled environments is reasonable; a persistent LocalMachine Bypass on production endpoints is not.
  • Undefined. No policy is set at this scope, so the session falls through to the next scope. It is the right value for scopes you want to inherit from a higher-priority setting. If every scope is Undefined, the effective policy is Restricted on Windows clients and RemoteSigned on Windows Server.

The Five Scopes and Precedence Order

Scopes are evaluated from highest to lowest priority. The first scope with a defined (not Undefined) value wins.

  • MachinePolicy. Set by Group Policy for all users on the machine. No local command can override it.
  • UserPolicy. Set by Group Policy for the current user. Also enforced by Group Policy, and also impossible to override locally.
  • Process. Applies only to the current session. It is held in the $Env:PSExecutionPolicyPreference variable and disappears when the session ends. It is the right scope for temporary exceptions and automation jobs.
  • CurrentUser. Applies to the current user. In Windows PowerShell 5.1 it is stored under HKCU. Standard users can write here without elevation, a detail that is easy to miss. That is exactly why local Set-ExecutionPolicy alone is not enough for fleet enforcement: a standard user can change their own scope.
  • LocalMachine. Applies to all users on the machine. In Windows PowerShell 5.1 it is stored under HKLM, and changing it needs elevation.

Group Policy wins. When MachinePolicy or UserPolicy is set through Group Policy, a local Set-ExecutionPolicy command will not change the effective policy. Run Get-ExecutionPolicy -List to see every scope and its value, not just the effective policy.

If you rely on -Scope Process for build pipelines or automation jobs, note that Process scope does not carry over between sessions. Each new session starts with whatever the scope chain says, so the parent process has to set it every time.

If Set-ExecutionPolicy reports that the setting is overridden by a policy defined at a more specific scope, check whether MachinePolicy or UserPolicy is already set through Group Policy. That is the scope that wins, and the local command has no effect on it.

PowerShell Execution Policy Types at a Glance

Policy typeScripts blocked?Signature required?Default onUse case
RestrictedAll scriptsN/AWindows clients (Windows PowerShell 5.1)Locked-down endpoints with no scripting need
AllSignedUnsigned scriptsYes, all scripts (local and remote)NoneEnvironments with a mature PKI; strictest scripting control
RemoteSignedUnsigned scripts from the internetInternet-origin scripts onlyWindows Server; PowerShell 7 on WindowsStandard enterprise baseline for managed endpoints
UnrestrictedNothing (prompts only)NoPowerShell 7 on Linux and macOS (fixed there)Non-Windows platforms; avoid on Windows production machines
BypassNothingNoNoneControlled automation and CI/CD pipelines, session scope only
UndefinedInherits from the next scopeN/AEvery scope not configuredIntentional fallthrough when a higher scope sets the rule

How to Check and Set PowerShell Execution Policy

Setting the execution policy correctly starts with knowing what is already configured, before you change anything. These are the commands you will use in practice.

Checking the Current Policy

Get-ExecutionPolicy returns the effective (winning) policy only. It does not tell you which scope enforces it or what the other scopes are set to.

Get-ExecutionPolicy -List returns all five scopes and their values, highest priority first. This is the command to run before any troubleshooting:

Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser    RemoteSigned
 LocalMachine      Restricted

Here the effective policy is RemoteSigned, because CurrentUser outranks LocalMachine. A scope that shows Undefined has no policy and falls through to the next one.

To check whether a specific script is tagged as an internet download, use:

Get-Item .\script.ps1 -Stream "Zone.Identifier"

This is checking for the Mark of the Web. If the stream shows ZoneId=3, the file comes from the internet zone and is blocked under RemoteSigned unless it is signed. To remove the tag:

Unblock-File -Path .\script.ps1

This removes the Zone.Identifier stream, so RemoteSigned treats the script as local. Note that some download methods, such as curl.exe and Invoke-WebRequest, may not add the tag at all.

Setting the Policy

Set RemoteSigned for all users on the machine (needs an elevated session):

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

This sets the LocalMachine scope. It affects all users, but a CurrentUser value or a Group Policy setting can override it.

Set Bypass for the current session only (no elevation needed):

Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process

This applies only to the current session and does not persist. It is the recommended approach for a temporary exception without changing the machine's standing policy.

Set RemoteSigned for the current user only:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

To remove a setting from a scope, set that scope to Undefined. Running these commands on 200 devices one at a time is not realistic, which is what the enforcement section below addresses.

Enforcing Execution Policy at Scale: GPO and MDM

Changing the execution policy on one machine is straightforward. Getting that change applied consistently across every endpoint in your fleet, and keeping it there, is the harder problem. There are two main paths, depending on how your environment is built.

Group Policy (On-Premises / Hybrid AD)

For domain-joined machines, configure the execution policy in Group Policy at this path:

Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell > Turn on Script Execution

Enabling the setting maps three options to policy types: Allow all scripts (Unrestricted), Allow local scripts and remote signed scripts (RemoteSigned) and Allow only signed scripts (AllSigned). Disabling it is the same as Restricted. The setting creates a MachinePolicy value, which overrides any local Set-ExecutionPolicy command, and users cannot change it. The same setting exists under User Configuration; the Computer Configuration one takes precedence.

For scripted auditing across the fleet, the Windows PowerShell 5.1 policy value is here:

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\PowerShell
  ExecutionPolicy (REG_SZ)

This Group Policy path applies to Windows PowerShell 5.1. PowerShell 7 ships its own administrative templates (PowerShellCoreExecutionPolicy.admx), and it stores local settings in powershell.config.json files instead of the registry. If both engines run on your machines, configure both.

MDM and Cloud-Managed Environments (No On-Prem GPO)

For Microsoft Entra joined, Intune-managed devices without on-premises Group Policy, the execution policy is set through the Intune Settings Catalog under Windows PowerShell. The MDM setting applies the same Turn on Script Execution policy, so users cannot override it locally. That answers one of the most common questions from cloud-first admins: how to enforce the execution policy when there is no on-premises Group Policy.

One thing worth naming: getting a Group Policy change approved through change control, tested in a lab and staged to production usually takes longer than the technical change itself. Build that into your plan.

How should I enforce execution policy across my fleet?

  • On-premises Active Directory with Group Policy: use the GPO (Turn on Script Execution). It creates the MachinePolicy scope, and no user can override it.
  • Microsoft Entra joined devices managed by Intune: use the Intune Settings Catalog Windows PowerShell setting. The enforcement result is the same.
  • Mixed on-premises and cloud-joined devices: use the GPO for domain-joined devices and Intune for Entra joined devices.
  • Not sure: run Get-ExecutionPolicy -List on a sample of devices. If MachinePolicy shows a value, Group Policy is already in play. If everything is Undefined or only LocalMachine is set, you have no fleet enforcement yet.

Why Execution Policy Alone Is Not Enough, and What to Use Alongside It

Execution policy on its own prevents accidents, not attacks. The documented bypass techniques take seconds for anyone who knows them, and MITRE ATT&CK tracks PowerShell abuse as its own technique, T1059.001. Execution policy will not stop it.

Common bypass approaches include passing -ExecutionPolicy Bypass to powershell.exe, encoding script content in Base64, running script text through Invoke-Expression, loading script content straight into memory, and using the PowerShell 2.0 engine, which predates many modern controls. Admins who set Unrestricted to unblock a problem script quickly create exactly the gap these techniques use: a persistent, machine-wide setting with no audit trail.

The PowerShell 2.0 downgrade matters most, because it gets around both execution policy and AMSI. Disabling PowerShell 2.0 is covered in the AMSI section below.

This is why Script Block Logging and AMSI belong on top of execution policy. The full stack is what makes the environment defensible, not any single setting.

AMSI (Antimalware Scan Interface)

AMSI passes PowerShell script content to the installed antimalware product at runtime, independent of execution policy. Even when the policy is Bypass, a compatible antivirus or EDR product can still detect and block malicious content before it runs. AMSI is available on Windows 10, Windows Server 2016 and later, and works when a compatible security product is installed.

One gap: the PowerShell 2.0 engine predates AMSI, so a downgrade to it avoids the scan. That is why the DISA STIG for Windows 10 requires PowerShell 2.0 to be disabled (WN10-00-000155).

If AMSI blocks a script you know is safe, the cause is usually pattern matching. The fix is an exclusion for that specific script in your antivirus or EDR product, not disabling AMSI.

Script Block Logging (Event ID 4104)

Script Block Logging records the content of executed script blocks, whatever the execution policy. A script run with Bypass is still logged. Without it there is no forensic record of what ran.

Enable it in Group Policy: Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell > Turn on PowerShell Script Block Logging. Events appear as Event ID 4104 in the Microsoft-Windows-PowerShell/Operational log.

Once you enable Script Block Logging, expect a clear increase in log volume on endpoints. Make sure your SIEM or log forwarding can handle the extra data before you enable it fleet-wide.

Constrained Language Mode and WDAC

Constrained Language Mode restricts which .NET types and PowerShell language elements a session can use, which breaks many attack techniques even when execution policy is bypassed. Windows Defender Application Control (WDAC, now called App Control for Business) applies it automatically when script enforcement is on. For remoting, Just Enough Administration (JEA) adds another layer by restricting which cmdlets a user can run, whatever the execution policy.

AllSigned Policy and Code Signing in Practice

AllSigned is the strictest scripting policy available and technically the most secure. The reason most mid-sized organizations do not use it is operational, not technical.

To run AllSigned across a fleet, you need a PKI (Active Directory Certificate Services internally, or a commercial CA), certificates with the Code Signing EKU (OID 1.3.6.1.5.5.7.3.3), and a consistent process for signing every script before deployment. The key commands:

Set-AuthenticodeSignature -FilePath .\script.ps1 -Certificate $cert   # signs a script
Get-AuthenticodeSignature .\script.ps1                                  # checks the signature
New-SelfSignedCertificate                                               # lab use only

That last point matters: a self-signed certificate is not trusted on other machines unless you distribute it, so a certificate that works where it was created fails everywhere else. This is not a PowerShell quirk; it is how certificate trust works.

The friction in AllSigned is usually not the PKI setup itself. It is getting every script author to sign every script before deployment, and keeping that discipline across teams over time.

Most mid-sized organizations settle on RemoteSigned plus Script Block Logging plus GPO or MDM enforcement as their practical baseline. AllSigned is the right answer for high-security environments with the PKI and the discipline to support it. Both are defensible choices, and the decision depends on your actual risk and operational capacity.

Execution Policy and Compliance Frameworks

Execution policy is rarely a single checkbox in a compliance audit. It shows up as evidence under several controls across several frameworks. The common thread is that the policy needs to be documented, enforced through GPO or MDM, and auditable.

  • CIS Benchmarks for Windows: recommend PowerShell Script Block Logging and disabling PowerShell 2.0. Check the benchmark version you audit against for its execution policy recommendation.
  • NIST SP 800-53 Rev. 5: CM-7 (Least Functionality) and SI-3 (Malicious Code Protection) apply. CM-7 asks you to restrict software and functions to what the business needs, and uncontrolled script execution conflicts with it.
  • NIST SP 800-171 Rev. 3 (May 2024): requirement 03.04.06 (Least Functionality) supports a RemoteSigned or AllSigned baseline in environments that handle Controlled Unclassified Information. Rev. 3 renumbered the requirements, so check the mapping if you used Rev. 2.
  • DISA STIG for Windows 10: two pass or fail checks relate to PowerShell: WN10-CC-000326 (PowerShell Script Block Logging must be enabled) and WN10-00-000155 (PowerShell 2.0 must be disabled).
  • SOC 2 (AICPA Trust Services Criteria): no specific execution policy requirement. Enforced execution policy and script logging can support evidence for controls under CC6.1 and CC7.1.
  • ISO/IEC 27001:2022: Annex A controls 8.9 (Configuration management) and 8.19 (Installation of software on operational systems) are relevant, because uncontrolled script execution can break configuration change control.

Managing this across many devices

Configuring the execution policy on one machine takes 30 seconds; knowing what it is on 200 machines is the hard part. trio.so runs scripts on enrolled Windows PCs from the console, so you can write a Get-ExecutionPolicy -List check once and run it on the PCs that need it. See remote terminal and script runs.

The trio.so Create script wizard with a PowerShell script that runs Get-ExecutionPolicy -List.
In trio.so, IT writes one PowerShell check and runs it on enrolled Windows PCs.

Related reading: how to back up files from Command Prompt, how to remove a service with CMD, how to disable startup programs from Command Prompt and how to enable System Protection from Command Prompt.

Ready-to-use Templates

Must-have Template Toolkit for IT Admins

Explore All
Template Toolkit

Check the execution policy on every PC

trio.so runs PowerShell scripts on enrolled Windows PCs from one console.

Start free trial

Manage Every Device From One Console

trio.so brings device management, patching and security policies for Windows, macOS, Linux, iOS/iPadOS and Android into one console. Enroll a device and see it in the console within minutes.

14-day free trial. No credit card required.

trio.so brings device management, patching and security policies for Windows, macOS, Linux, iOS/iPadOS and Android into one console. Enroll a device and see it in the console within minutes.

Smiling womanAbstract geometric patternAbstract geometric patternSmiling womanSmiling woman

Frequently Asked Questions (FAQ)

Have questions? We've got answers. This section covers some of the most commonly asked questions related to this topic.

Run Set-ExecutionPolicy RemoteSigned -Scope CurrentUser. It lets your own local scripts run without admin rights. For a single downloaded script you trust, run Unblock-File on it instead. If the setting does not change, Group Policy controls it.

In Windows PowerShell 5.1 it is Restricted on Windows client computers and RemoteSigned on Windows Server. Microsoft's PowerShell 7 documentation lists RemoteSigned as its default on Windows.

The flag sets the Process scope, which beats CurrentUser and LocalMachine but not MachinePolicy or UserPolicy. When Group Policy sets the policy, the Group Policy value stays in force for that session. Run Get-ExecutionPolicy -List to see which scope controls the machine.

Yes, but the effective policy depends on the account the task runs under. A task running as SYSTEM or a service account uses LocalMachine (plus MachinePolicy or UserPolicy if Group Policy sets them). A policy set only at CurrentUser for one person does not apply to service account sessions. This is a common cause of "works in my console, fails in the task".

Yes. They keep separate settings: Windows PowerShell 5.1 uses the registry and its own Group Policy template, while PowerShell 7 uses powershell.config.json files and its own templates. Run Get-ExecutionPolicy -List in each engine to confirm both.

Not a security boundary. Microsoft calls it defense in depth: it stops accidental script runs, and anyone can bypass it. Pair it with Script Block Logging, AMSI and application control.

Run Get-ExecutionPolicy -List on each machine through PowerShell remoting (Invoke-Command), read the policy registry values remotely, or use a management tool that runs a script on many devices and shows the results in one place.

Related

From the blog

The related industry news, interviews, technologies, and resources.