That message is Windows PowerShell refusing to run a .ps1 file because its execution policy is set to Restricted — the default on client editions of Windows. Check it by running Get-ExecutionPolicy -List in the same window that failed; if every scope reads Undefined or Restricted, you've found the cause. The fix is one command: Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned, confirmed with Y, then re-run your script. You do not need to touch the registry, and you should not reach for Unblock-File first — that clears a different flag and won't move the policy.

The error text usually continues with a path, something like C:\Scripts\deploy.ps1 cannot be loaded because running scripts is disabled on this system. That trailing path matters, because the policy is evaluated per scope and per process — a script that runs fine in one window can fail in another if the two windows were launched with different policy settings. Below is the full diagnosis, the fix ranked by blast radius, the failure cases most guides skip, and how to undo everything.

What the Execution Policy Actually Blocks and What It Leaves Alone

The execution policy governs .ps1 script files and PowerShell modules, nothing else. Typing Get-Process at the prompt still works under Restricted, and so does a one-liner pasted into the console. Microsoft's own documentation is explicit that this is a safety feature, not a security boundary — a determined user can bypass it, and Microsoft says so, which is why administrators shouldn't treat it as an access control.

Four policies cover almost every case you'll meet. Restricted blocks all script files and is the default on Windows client editions. RemoteSigned allows locally created scripts to run unsigned while requiring a digital signature on anything downloaded from the internet, identified by the Zone.Identifier alternate data stream (the "mark of the web"). AllSigned requires a trusted signature on every script, local or not. Unrestricted runs everything but still prompts before running a downloaded file.

Five scopes decide which policy wins: MachinePolicy and UserPolicy (set by Group Policy and unoverridable from the console), Process (this window only, gone when it closes), CurrentUser, and LocalMachine. PowerShell evaluates them in that order, and the first one that isn't Undefined wins. That precedence is why a Set-ExecutionPolicy command can appear to succeed and change nothing — if a domain policy sits at MachinePolicy, your CurrentUser setting is silently outranked.

One version wrinkle worth knowing: Windows PowerShell 5.1 and PowerShell 7 keep separate policy stores on the same machine. Changing the policy in powershell.exe does not change it in pwsh.exe, and vice versa. If your script fails in one shell but not the other, you're looking at two different registries, not a bug.

Read Your Current Policy Before Changing Anything

Run Get-ExecutionPolicy -List first. It returns a five-row table — one row per scope — and the effective policy is the first non-Undefined entry from the top. A machine where nobody has configured anything typically shows Undefined for MachinePolicy, UserPolicy, Process, and CurrentUser, and Restricted for LocalMachine.

Pay attention to which shell you're in. The window title bar tells you: "Windows PowerShell" is 5.1, "PowerShell 7" is the newer cross-platform build. Run $PSVersionTable.PSVersion if the title is ambiguous — the Major value is 5 or 7. Whatever you change, change it in the shell that produced the error, or the error will persist.

If MachinePolicy or UserPolicy shows anything other than Undefined, stop and talk to whoever manages your domain. Those two scopes come from Group Policy and cannot be overridden with Set-ExecutionPolicy; the command will either fail or write a value that never takes effect. This is the single most common reason a "fix" doesn't stick on a work laptop.

Check also whether the failure is a policy problem at all. If Get-ExecutionPolicy returns RemoteSigned and the script still won't load, the policy isn't your blocker — the file is likely blocked by the mark of the web, and Unblock-File -Path .\yourscript.ps1 is the right tool. Jumping straight to policy changes when a file is merely blocked is wasted effort and unnecessary risk.

Fix One: Set the Policy for Your Own Account

This is the fix to try first, because it needs no administrator rights and affects only your user profile. Open the same PowerShell window that showed the error — no elevation required — and run the command in step 1, then confirm at the prompt.

1: Run Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned. 2: Type Y and press Enter when asked whether you want to change the execution policy. 3: Verify with Get-ExecutionPolicy -List and confirm the CurrentUser row now reads RemoteSigned. 4: Re-run your script by its full path, for example .\deploy.ps1 from its folder. 5: If the script came from a download, run Unblock-File -Path .\deploy.ps1 as well, then re-run it.

RemoteSigned is the right default here because it permits scripts you wrote or received locally while still requiring a signature on anything that arrived from the internet. That keeps the protection that matters for most home and small-office machines without the constant friction of Restricted. If step 1 errors with "Access to the registry key is denied," the CurrentUser scope has been locked down by policy, and you're back to the Group Policy conversation above.

If the command runs but the script still fails, check the scope list again — the Process scope may have been set to Restricted by a launcher or shortcut, which will override CurrentUser for that window only. Opening a fresh PowerShell window clears it. This edge case catches people who set the policy correctly and then launch their script from a tool that pins the process scope.

Fix Two: Bypass for a Single Session

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass changes the policy for the current window only, and the setting evaporates when the window closes. It's the correct choice on a shared or managed machine where you can't or shouldn't make a persistent change, and it's also the safest way to test whether the policy is genuinely the cause of your error.

The classic use is a scheduled task or a CI runner. For a one-off invocation you can skip the policy change entirely: powershell.exe -ExecutionPolicy Bypass -File C:\Scripts\deploy.ps1 runs that single file with the policy bypassed for the life of that process. Task Scheduler actions and build agents commonly use this form, and it's cleaner than permanently loosening a server's policy for one script.

Understand the risk before you adopt it as a habit. Bypass runs everything without prompts, including a malicious script that lands in your downloads folder and gets double-clicked. The process scope limits the blast radius to one window, but if that window is running an unattended deployment, nothing is watching. Reserve Bypass for sessions where you know exactly which script you're invoking and where it came from.

A related trap: -ExecutionPolicy Bypass on the command line affects the child process only. It does not change what Get-ExecutionPolicy reports in your interactive window afterward, and it does not persist. If someone tells you they "fixed it" this way and the error returns tomorrow, they changed nothing — they just ran the script once.

Fix Three: Machine-Wide Change on a Machine You Control

On a personal workstation or a lab box where you're the administrator, Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine from an elevated PowerShell window sets the default for every user on the box. Run PowerShell as Administrator (right-click, "Run as administrator"), execute the command, confirm with Y, and verify the LocalMachine row flips to RemoteSigned.

Elevation is required for LocalMachine, and a standard user account will get an access-denied error. That's the design working as intended — a machine-wide policy change is an administrative act. If you're on a work computer and you don't hold local admin, this path is closed, and you should use the CurrentUser or Process scope instead rather than hunting for a workaround.

This scope is the one to pick when you're provisioning a new development machine and want the setting to survive for every account. It's also the scope Group Policy writes to when a domain pushes a policy, which means your change can be overwritten at the next policy refresh — typically within 90 minutes plus a random offset on domain-joined machines, per Microsoft's Group Policy refresh defaults. On a non-domain machine, nothing overwrites it.

One caveat that trips up IT generalists: changing LocalMachine in Windows PowerShell 5.1 leaves PowerShell 7's LocalMachine value alone. If both shells are in use on the machine, set the policy in both, or standardize on one shell for script execution.

RemoteSigned, AllSigned, Unrestricted, Bypass: Which One to Actually Pick

Choosing a policy is the part most guides skim, and it's where the wrong default gets baked into a fleet of machines. The table below compares the four policies you'll realistically choose between; the "Who it suits" column is the practical decision.

Policy Runs local scripts Runs downloaded scripts Prompts before running Who it suits
Restricted No No No Shared kiosks and locked-down endpoints with no scripting need
RemoteSigned Yes Only if signed by a trusted publisher No Developer workstations, home PCs, most small offices
AllSigned Only if signed Only if signed No Regulated environments with an internal code-signing certificate
Bypass Yes Yes No Single-session troubleshooting and unattended one-off invocations
Unrestricted Yes Yes Yes, for downloaded files Legacy compatibility only; Microsoft discourages it

The winner for nearly every reader who hit this error is RemoteSigned at CurrentUser. It removes the friction that stopped your script while keeping the signature requirement on downloaded code — which is exactly the threat the policy exists to slow down. AllSigned is the choice only if your organization already issues code-signing certificates and has a process for signing internal scripts; without that infrastructure it just moves the error from "scripts disabled" to "script not digitally signed."

Skip Unrestricted. Microsoft's documentation warns that it runs downloaded scripts after a prompt, and the prompt is the only gate — a user who clicks through it has no protection at all. The one honest drawback of the RemoteSigned recommendation: it will still block a signed script whose certificate has expired or whose publisher isn't in your Trusted Publishers store, and the error message in that case is different ("not digitally signed" rather than "running scripts is disabled"). If you meet that second error, the policy is fine and the certificate is the problem.

Undoing the Change and Locking It Back Down

Every fix here is reversible, and you should know the undo before you make the change — especially on a machine you don't own. To revert your own scope, run Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Undefined, which removes your setting and lets the machine default apply again. For the machine scope, use Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy Restricted from an elevated window on a client edition.

Undefined is not the same as Restricted. Setting a scope to Undefined deletes the value at that scope so the next scope down in the precedence chain takes over; setting it to Restricted actively blocks scripts at that scope. If you want the machine back to its out-of-box behavior, Undefined at CurrentUser plus Restricted at LocalMachine reproduces a fresh Windows install.

Check the registry if a command-line change doesn't seem to take. The policy values live under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell for the machine scope and HKEY_CURRENT_USER\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell for the current user, with the value name ExecutionPolicy. Microsoft's documentation names these keys, and reading them is a quick way to confirm whether your change landed or whether something else is writing over it.

If the machine belongs to an employer, revert before you hand it back. A leftover Bypass or Unrestricted at LocalMachine on a corporate laptop is the kind of thing that shows up in an audit, and it wasn't yours to change in the first place.

Five Failure Cases That Survive the Usual Fix

The standard advice — set RemoteSigned, done — fails in a handful of situations, and each has a distinct signature. Recognizing the signature saves an hour of guessing.

Group Policy wins. If Get-ExecutionPolicy -List shows MachinePolicy or UserPolicy set to Restricted or AllSigned, your CurrentUser change is overruled and the error persists. The command may even succeed silently. Only a domain administrator can change this, by editing the policy object that sets it.

The script is blocked, not disabled. The error "cannot be loaded. The file is not digitally signed" or a security-warning prompt means the policy allows the script but the file carries the mark of the web. Unblock-File fixes it; policy changes don't.

Wrong shell. You fixed it in PowerShell 7 and your scheduled task runs powershell.exe (5.1), or the reverse. The two stores are independent, so the fix has to be applied in the shell that actually runs the script.

Constrained Language Mode or AppLocker. On heavily managed machines, $ExecutionContext.SessionState.LanguageMode may return ConstrainedLanguage, and AppLocker or Windows Defender Application Control may block script execution regardless of policy. In that case the execution policy is a red herring — the block is a separate control, and only the administrator who set it can lift it.

The path has a space or a blocked character. Occasionally the error is a file-path problem wearing the policy error's clothes: an unquoted path with spaces, or a script sitting in a folder the user can't read. Test by running the script from C:\Temp with a short name; if it loads there, the policy was never the issue.

FAQ

Does changing the execution policy weaken Windows security?

Yes, somewhat, and the amount depends on which policy you pick. Moving from Restricted to RemoteSigned lets any locally created script run without a prompt, so malware that writes a .ps1 to disk and executes it locally is no longer stopped by the policy. Microsoft states plainly that the execution policy is not a security boundary and can be bypassed by a motivated attacker, so treat it as friction against accidental execution rather than a wall.

Why does the error come back after I close and reopen PowerShell?

Because you set the policy at the Process scope, which lasts only for that window. Set-ExecutionPolicy -Scope Process is designed for one session and is discarded on exit. Run Get-ExecutionPolicy -List in the new window; if CurrentUser and LocalMachine are both Undefined or Restricted, the earlier change never persisted and you need the CurrentUser scope instead.

Can I run just one script without changing the policy at all?

Yes — invoke it with powershell.exe -ExecutionPolicy Bypass -File C:\path\to\script.ps1 from Command Prompt, or pwsh -ExecutionPolicy Bypass -File for PowerShell 7. The bypass applies to that process only and leaves every stored policy untouched, which is the cleanest option on a machine you don't administer. It's also the standard form used in Task Scheduler actions for one-off scripts.

Does the policy apply to PowerShell 7 the same way as Windows PowerShell 5.1?

No. The two shells read and write separate policy stores, so a change in one has no effect on the other. If your script fails under pwsh but works under powershell, set the policy again inside pwsh. Verify the shell version with $PSVersionTable.PSVersion before troubleshooting further, because the fix has to land in the right store.

What does "running scripts is disabled on this system" mean if I'm an administrator?

It means the effective policy is still Restricted or AllSigned for the scope that applies, even though you hold admin rights. Admin rights let you change the LocalMachine scope, but they don't override a MachinePolicy set by Group Policy, and they don't change the CurrentUser scope of a different account. Check the full scope list; the top non-Undefined row is what's actually in force.

Is Unrestricted ever the right answer?

Rarely, and only for legacy compatibility on a machine with no internet access and no untrusted files. Unrestricted runs downloaded scripts after a single prompt, and Microsoft's documentation discourages it. If you think you need it, try RemoteSigned first — it unblocks local scripts, which is what almost everyone actually wanted when they reached for Unrestricted.

Does this error affect .bat and .cmd files too?

No. The execution policy applies to PowerShell script files and modules, not to batch files or executables. A .bat file that fails to run has a different cause — usually a permissions problem, a missing interpreter, or a blocked path — and changing the PowerShell execution policy won't help. Confirm which file type your failing command actually invokes before you start changing policy.