Quick fix
# One-liner: process-level temporary bypass (recommended; writes nothing to the registry)
powershell -NoProfile -ExecutionPolicy Bypass -File .\setup.ps1
Affects only the current process, changes no persistent settings; -NoProfile avoids interference from the user profile.
What you will run into
Running a PowerShell script fails immediately: File C:\path\setup.ps1 cannot be loaded because running scripts is disabled on this system. Interactive commands (Get-Process etc.) work fine — only "executing a script file" is blocked.
Common triggers: Windows client default Restricted, enterprise group policy lockdown, or a downloaded script carrying the MOTW mark being blocked by RemoteSigned.
Why this happens
| Key point | Explanation |
|---|---|
| Policy layering | MachinePolicy → UserPolicy → Process → CurrentUser → LocalMachine; earlier layers win |
-File doesn't bypass policy | powershell -File xxx.ps1 is still subject to execution policy — many people assume -File means it runs |
| RemoteSigned semantics | Local unsigned scripts run; scripts downloaded from the internet carry a Zone.Identifier (MOTW) mark and are blocked when unsigned |
| Changes not taking effect | Set-ExecutionPolicy RemoteSigned only changes CurrentUser by default; when an enterprise policy is not Undefined, user-level changes do nothing |
PowerShell execution policy is layered: MachinePolicy → UserPolicy → Process → CurrentUser → LocalMachine, with earlier layers winning.
powershell -File xxx.ps1 does not bypass the policy (many assume -File means it will run);
under RemoteSigned, scripts "downloaded from the internet" carry a Zone.Identifier (MOTW mark) and are blocked without a signature — locally created scripts are unaffected.
Two "changes do not take effect" traps: Set-ExecutionPolicy RemoteSigned only changes CurrentUser by default (LocalMachine needs admin, and user-level settings are ineffective while a policy layer is non-Undefined);
when enterprise policies (MachinePolicy/UserPolicy) are non-Undefined, all user-level settings are overridden.
Deterministic takeaway: run Get-ExecutionPolicy -List to see the full stack and find which layer is actually effective; a blocked downloaded script = unblock the MOTW (Unblock-File) instead of disabling the policy; a change not applying = check whether a higher layer overrides it;
fixed diagnostic: check -List before acting.
Step by step
1. Process-level temporary bypass — Required
powershell -NoProfile -ExecutionPolicy Bypass -File .\setup.ps1
2. Current-session level — Required
Set-ExecutionPolicy -Scope Process RemoteSigned
.\setup.ps1
Restored as soon as the window closes.
3. User-level persistent — Required
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
Get-ExecutionPolicy -List
Affects all sessions of the current user; confirm the CurrentUser row changed.
4. Enterprise / group policy lockdown — Required
When MachinePolicy is not Undefined, user-level commands are ineffective; an admin must relax it in group policy or grant an exception. Don't fight policy by hard-editing the registry locally.
5. Downloaded script blocked by RemoteSigned — Required
Unblock-File .\downloaded.ps1
Removes the MOTW mark (only when you trust the source).
How to confirm it works
The script runs normally (measured output shape):
powershell -ExecutionPolicy Bypass -File payload.ps1 → normal output, exit=0
Inspect current policy and layering: Get-ExecutionPolicy -List; check MOTW: Get-Content -Stream Zone.Identifier .\x.ps1.
Other environments
| Environment | Notes |
|---|---|
| Restricted | Blocks every script file (including local ones) |
| RemoteSigned | Local scripts run; downloaded scripts need Unblock-File or a signature |
| Enterprise policy | User-level commands ineffective; go through group policy |
| -File parameter | Doesn't bypass policy (measured: same error when restricted) |
| Not fully reproduced | Manually writing a Zone.Identifier wasn't blocked on this machine (MOTW cache/environment differences); mechanism per official docs |
Symptom
Running a PowerShell script fails immediately:
powershell -File .\setup.ps1
File C:\path\setup.ps1 cannot be loaded because running scripts is disabled on this system.
+ CategoryInfo : SecurityError: (:) [], ParentContainsRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess
.\script.ps1or& .\script.ps1from the prompt may fail with the same error.- Interactive commands (Get-Process, Set-Location, ...) work fine; only executing script files is blocked.
- Common triggers: Windows client default
Restricted; enterprise Group Policy locking MachinePolicy to Restricted/AllSigned; or a script downloaded from the internet (Zone.Identifier / MOTW) blocked under RemoteSigned without a signature.
Cause
- Layered policy: MachinePolicy > UserPolicy > Process > CurrentUser > LocalMachine (earlier wins).
Get-ExecutionPolicy -Listshows every layer.Restrictedblocks ALL script files, including local ones. - -File does NOT bypass policy:
powershell -File x.ps1is still subject to ExecutionPolicy. - RemoteSigned semantics: locally created unsigned scripts run, but scripts downloaded from the internet carry a Zone.Identifier (MOTW) and are blocked without a digital signature.
- Why the fix "doesn't stick":
Set-ExecutionPolicy RemoteSigneddefaults to the CurrentUser scope; it has no effect when MachinePolicy/UserPolicy is non-Undefined (enterprise), and LocalMachine changes need admin rights.
Solution
Pick in order "no system change → session → user → enterprise":
- Process-level bypass (recommended, no registry writes):
powershell -NoProfile -ExecutionPolicy Bypass -File .\setup.ps1
- Current session only:
Set-ExecutionPolicy -Scope Process RemoteSigned
.\setup.ps1
- Persistent for current user:
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
Get-ExecutionPolicy -List
- Enterprise/Group Policy locked (MachinePolicy non-Undefined): user-scope commands won't help; ask an admin to relax policy or request an exception. Do not fight policy by editing the registry locally.
- Downloaded script blocked under RemoteSigned (UnauthorizedAccess + file came from a browser):
Unblock-File .\downloaded.ps1— only when you trust the source.
Inspect layers: Get-ExecutionPolicy -List; check MOTW: Get-Content -Stream Zone.Identifier .\x.ps1.
Verification Evidence
- Baseline (Windows PowerShell 5.1, 2026-08-29): CurrentUser = RemoteSigned.
- Repro 1: process-scope Restricted +
-File payload.ps1→ "running scripts is disabled on this system" (SecurityError/UnauthorizedAccess), exit=1 — matches the user error verbatim. - Fix 1:
-ExecutionPolicy Bypass -File→ script runs, exit=0. - RemoteSigned semantics: local unsigned script runs under RemoteSigned, exit=0.
- Honest note: manually injected Zone.Identifier (ZoneId=3) was NOT blocked under RemoteSigned on this machine (MOTW cache/environment difference) — the "downloaded script blocked" scenario was not fully reproduced; mechanism and fix commands follow the official docs.
Evidence details kept locally (2026-08-29)
Applicable tools (1)
This problem is linked from the tool pages below — reachable from either side.
powershellBundled solutions (combos)
This problem is part of the following verified bundles.
Source & evidence
← Coding Agents & Terminal domain | Problem Catalog Experience | Facing another issue? Go to the Helpdesk