# "Running scripts is disabled" for codex, claude or gemini

> codex.ps1 cannot be loaded because PowerShell blocks the .ps1 shim npm writes. Type codex.cmd, or allow RemoteSigned for your own Windows account.

Source: https://shuriken.sh/guides/running-scripts-is-disabled-agent-cli

PowerShell refuses codex.ps1, claude.ps1 or gemini.ps1 because npm puts a .ps1 shim next to each CLI's .cmd shim, and Windows PowerShell starts at the Restricted policy on Windows 10 and 11. Type codex.cmd for a one-off, or run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned once.

By Shuriken Updated 27 October 2026 4 min read

**Contents**

"codex.ps1 cannot be loaded because running scripts is disabled on this system" is PowerShell's execution policy refusing the small .ps1 launcher npm wrote for Codex. For a one-off, type codex.cmd; to fix it for your account, run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser once. claude.ps1, gemini.ps1 and copilot.ps1 fail the same way and take the same fix.

## Why PowerShell says codex.ps1 cannot be loaded #

npm on Windows puts global executables straight into its prefix folder, %AppData%\npm unless you changed it ([npm's folders page](https://docs.npmjs.com/cli/v11/configuring-npm/folders/)). Its cmd-shim module then writes three launchers per executable ([its source](https://github.com/npm/cmd-shim/blob/main/lib/index.js)): codex for Unix-style shells, codex.cmd for Command Prompt, codex.ps1 for PowerShell.

Type codex at a PowerShell prompt and PowerShell picks codex.ps1. The error shows it, since it names the exact file:

text
codex : File C:\Users\you\AppData\Roaming\npm\codex.ps1 cannot be loaded because running scripts
is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.

Windows PowerShell 5.1, the one built into Windows 10 and 11, uses the Restricted policy on client computers unless someone changed it. [Microsoft's page on execution policies](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1) says Restricted "permits individual commands, but doesn't allow scripts", so a fresh PC blocks every .ps1, npm shims included. The same page also says the policy "isn't a security boundary, it's defense in depth".

## Which coding agents hit it #

Any agent you installed with npm install -g on Windows has a .ps1 shim. A native .exe doesn't.

| Agent | npm install (has a .ps1 shim) | Other Windows install the vendor documents |
| --- | --- | --- |
| Codex | npm install -g @openai/codex | PowerShell installer from the README, which puts codex.exe on your PATH |
| Claude Code | npm install -g @anthropic-ai/claude-code | Native installer irm https://claude.ai/install.ps1 | iex , or winget install Anthropic.ClaudeCode |
| Gemini CLI | npm install -g @google/gemini-cli | None listed for Windows |
| GitHub Copilot CLI | npm install -g @github/copilot | winget install GitHub.Copilot |

Sources, read on 24 October 2026: [Claude Code setup](https://code.claude.com/docs/en/setup), [the Codex README](https://github.com/openai/codex), [Gemini CLI installation](https://geminicli.com/docs/get-started/installation/) and [GitHub's Copilot CLI install page](https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/install-copilot-cli). Anthropic recommends its native installer, which leaves claude.exe in %USERPROFILE%\.local\bin. So if your error names claude.ps1, you have an npm-style install. If claude isn't found at all after the native install, that is a PATH problem, covered in [claude: command not found](https://shuriken.sh/guides/claude-command-not-found).

## How to fix "running scripts is disabled", smallest change first #

- codex.cmd, claude.cmd, gemini.cmd or copilot.cmd: with the extension typed out, PowerShell runs the batch launcher and never touches the .ps1. Microsoft's [command precedence page](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_command_precedence) gives the same trick, with where.exe as its example. In Command Prompt plain codex already works, because cmd runs the .cmd. And if npm itself stops on npm.ps1 while you install, npm.cmd install -g @openai/codex gets past it.
- Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process lasts until you close that PowerShell window.
- Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser is the lasting one, for your account only. It applies at once, without a restart, and without an administrator window: Microsoft asks for one only for the LocalMachine scope.
- Or replace the npm install with a .exe: Anthropic's native installer for Claude Code, OpenAI's standalone installer for Codex. Remove the npm copy first (npm uninstall -g @openai/codex), otherwise both stay on your PATH.

RemoteSigned is enough here because npm writes the shims on your own computer. Under RemoteSigned, scripts "written on the local computer and not downloaded from the internet" run without a signature, and downloaded unsigned scripts are still blocked until you unblock them. Leave Unrestricted and Bypass alone as standing settings: Bypass blocks nothing and shows no warnings, and Unrestricted runs unsigned scripts from anywhere, with only a warning for ones from outside your local intranet.

Shuriken runs Claude Code, Codex, Gemini CLI and 64 more agents side by side, with your own sign-ins.

[Download](https://shuriken.sh/download)

## When Set-ExecutionPolicy doesn't stick #

Get-ExecutionPolicy -List prints one row per scope, and on a managed work PC two of those rows belong to Group Policy. A value other than Undefined in MachinePolicy or UserPolicy was set there, usually by your IT department, and Microsoft's docs say it overrides every scope you can change yourself. That is how Set-ExecutionPolicy can succeed and change nothing. Keep typing codex.cmd, or ask IT for RemoteSigned.

Two PowerShells on one PC cause the other surprise. Windows PowerShell 5.1 stores your CurrentUser policy in the registry; PowerShell 7 (pwsh) stores it in a powershell.config.json file ([Microsoft's page for 7.6](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.6)). Set it in one and the other never sees it, so run the command in whichever window printed the error.

If you prefer WSL for agents altogether, PowerShell's policy doesn't apply inside it; the trade-offs are in [Claude Code on Windows: native or WSL?](https://shuriken.sh/guides/claude-code-windows-vs-wsl), and the Codex side is in [Codex CLI on Windows](https://shuriken.sh/guides/codex-cli-on-windows).

## How Shuriken avoids the .ps1 shim #

Shuriken installs the agent CLIs on each Windows PC itself, so you don't type npm install -g yourself. Claude Code comes from Anthropic's native installer, with npm as the fallback. npm agents go into a folder of Shuriken's own, not %AppData%\npm. Shuriken then starts each agent from its .exe, or from its .cmd through cmd.exe, so the .ps1 shim never runs and your execution policy never comes into it. Terminal tabs in Shuriken open cmd.exe on Windows.

An agent can still run a PowerShell script of yours and hit the policy mid-chat. From 5.1, Shuriken reads that error in the agent's output and shows a card in the chat, "PowerShell blocked Codex's script", with the CurrentUser RemoteSigned command and a copy button. The rest of what runs on Windows is in [Shuriken on Windows 10 and 11](https://shuriken.sh/blog/shuriken-on-windows), and the installer is on the [download page](https://shuriken.sh/download).

Share

[X](https://x.com/intent/post?url=https%3A%2F%2Fshuriken.sh%2Fguides%2Frunning-scripts-is-disabled-agent-cli&text=%22Running%20scripts%20is%20disabled%22%20for%20codex%2C%20claude%20or%20gemini)[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fshuriken.sh%2Fguides%2Frunning-scripts-is-disabled-agent-cli)[Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fshuriken.sh%2Fguides%2Frunning-scripts-is-disabled-agent-cli&t=%22Running%20scripts%20is%20disabled%22%20for%20codex%2C%20claude%20or%20gemini)[Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fshuriken.sh%2Fguides%2Frunning-scripts-is-disabled-agent-cli&title=%22Running%20scripts%20is%20disabled%22%20for%20codex%2C%20claude%20or%20gemini)[E-mail](mailto:?subject=%22Running%20scripts%20is%20disabled%22%20for%20codex%2C%20claude%20or%20gemini&body=https%3A%2F%2Fshuriken.sh%2Fguides%2Frunning-scripts-is-disabled-agent-cli)

## Sources

- [about_Execution_Policies, PowerShell 5.1 (Microsoft Learn)](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1) (accessed 24 October 2026)
- [about_Execution_Policies, PowerShell 7.6 (Microsoft Learn)](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.6) (accessed 24 October 2026)
- [about_Command_Precedence (Microsoft Learn)](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_command_precedence) (accessed 24 October 2026)
- [npm docs: folders (global executables on Windows)](https://docs.npmjs.com/cli/v11/configuring-npm/folders/) (accessed 24 October 2026)
- [npm/cmd-shim source: lib/index.js](https://github.com/npm/cmd-shim/blob/main/lib/index.js) (accessed 24 October 2026)
- [Claude Code docs: Advanced setup](https://code.claude.com/docs/en/setup) (accessed 24 October 2026)
- [openai/codex README: Quickstart](https://github.com/openai/codex) (accessed 24 October 2026)
- [Gemini CLI docs: Installation](https://geminicli.com/docs/get-started/installation/) (accessed 24 October 2026)
- [GitHub Docs: Installing GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/install-copilot-cli) (accessed 24 October 2026)

## Frequently asked questions

**Is Set-ExecutionPolicy RemoteSigned safe?**

Microsoft ships RemoteSigned as the default on Windows Server. Scripts written on your PC, npm's shims among them, run unsigned, while a .ps1 downloaded from the internet needs a trusted signature or Unblock-File first. With -Scope CurrentUser, no other account on the PC changes.

**Do I need to run PowerShell as administrator to fix it?**

No. Microsoft's docs say you need Run as administrator only for -Scope LocalMachine. The CurrentUser command runs in the same ordinary PowerShell window that showed you the error.

**Why does codex work in Command Prompt but not in PowerShell?**

In cmd.exe, codex runs codex.cmd, a batch file, and no execution policy applies to batch files. PowerShell picks codex.ps1 from %AppData%\npm instead, and Restricted blocks every .ps1.

**Why does Set-ExecutionPolicy not fix it on my work laptop?**

Group Policy wins over every scope you can set yourself. Run Get-ExecutionPolicy -List: a value in the MachinePolicy or UserPolicy row comes from Group Policy, usually set by your IT department. Call codex.cmd instead, or ask them for RemoteSigned.

**Does the native Claude Code installer have this problem?**

Not when Claude Code runs from it. Anthropic's native installer puts claude.exe in %USERPROFILE%\.local\bin, and a .exe isn't a script. An error that names claude.ps1 comes from an install through npm or a similar package manager.

Every coding agent

67 coding agents, one harness.

Run Claude Code, Codex, Gemini CLI and the rest on your own computers, with the sign-ins you already have.

[Download](https://shuriken.sh/download)

[Other platforms](https://shuriken.sh/download#main)

## Keep reading

- [AGENTS.md vs CLAUDE.md: one file for every agent?: Comparison 27 Oct 2026 6 min read AGENTS.md vs CLAUDE.md: Codex reads AGENTS.md, Claude Code reads it when there is no CLAUDE.md or through @AGENTS.md, Gemini CLI once you list it.](https://shuriken.sh/compare/agents-md-vs-claude-md)
- [Codex CLI approval modes and sandbox, explained: Guide 27 Oct 2026 5 min read Codex CLI approval modes are two settings: the sandbox and the approval policy. Auto pairs workspace-write with on-request; untrusted is retired.](https://shuriken.sh/guides/codex-cli-approval-modes)
- [Codex CLI config.toml: where it lives and what to set: Guide 27 Oct 2026 4 min read Codex reads ~/.codex/config.toml, a trusted project's .codex/config.toml, a profile and -c flags. Flags win, then the closest project file.](https://shuriken.sh/guides/codex-cli-config-toml)

## Free tools

- [Claude limit reset tracker](https://shuriken.sh/tools/limit-resets/claude)
- [Codex limit reset tracker](https://shuriken.sh/tools/limit-resets/codex)
