Codex App: In a Windows environment, Codex cannot initialize PowerShell
Open 💬 9 comments Opened Apr 29, 2026 by VentureDuan
💡 Likely answer: A maintainer (github-actions[bot], contributor)
responded on this thread — see the highlighted reply below.
What version of the Codex App are you using (From “About Codex” dialog)?
codex app 26.426.12240
What subscription do you have?
plus
What platform is your computer?
x64
9 Comments
Windows:
shell_commandfails during PowerShell initialization withInitialSessionState/GetSaferPolicy/Win32Exception (126), while manual PowerShell worksSummary
On Windows, Codex Desktop
shell_commandfails before the actual command runs.The failure happens during PowerShell initialization, with this stack shape:
System.Management.Automation.Runspaces.InitialSessionStateSystem.Management.Automation.Internal.SecuritySupport.GetSaferPolicySystem.Management.Automation.Security.SystemPolicy.GetAppLockerPolicySystem.ComponentModel.Win32Exception (126): The specified module could not be foundImportant context:
powershell.exeworkspwsh.exeworksenv_mapandcwdcaptured from Codex sandbox requests in a normal child process also worksshell_commandrunner / sandbox host environmentThis looks very similar to:
What version of the Codex App are you using?
Observed local package versions/log references include:
OpenAI.Codex_26.415.4716.0_x64__2p2nqsd0c76g0OpenAI.Codex_26.422.3464.0_x64__2p2nqsd0c76g0The failing local runner path observed in logs is:
C:\Users\Administrator\.codex\.sandbox-bin\codex-command-runner-0.125.0-alpha.3.exePlatform
Repro
Inside Codex Desktop, ask the agent to run even a trivial shell command, for example:
or:
Actual behavior
shell_commandfails before the command executes.Observed error:
Expected behavior
shell_commandshould run the command successfully, the same way it works in a normal Windows terminal.Important findings from local investigation
1. Manual PowerShell works
These succeed outside Codex
shell_command:pwsh.exeversion on this machine is:2. Replaying Codex sandbox env works in a normal child process
I extracted a real Codex sandbox request JSON from:
Using the same:
cwdenv_mapI replayed
powershell.exein a normal child process, and it worked.That suggests the problem is not caused by:
It points more specifically to the Codex runner / sandbox token / host environment.
3. AppLocker-related system components appear present and healthy
Checked locally:
C:\Windows\System32\appidapi.dllexistsC:\Windows\System32\wldp.dllexistsAppIDSvcis runningAppLockerFltris runningNormal PowerShell also reports:
FullLanguageExecution policy is not obviously abnormal.
4. Codex logs show
shell_commanduses Windows PowerShell through the command runnerObserved in local files:
C:\Users\Administrator\.codex\.sandbox\sandbox.logC:\Users\Administrator\.codex\archived_sessions\rollout-2026-04-24T19-02-17-019dbf27-9db1-7963-9dd0-8c8d732d2f97.jsonlExamples show the runner invoking:
and the failing runner binary observed in logs is:
Additional notes
I also changed the local integrated terminal preference from
powershelltopwsh, but that did not fixshell_command.This suggests that:
shell_commandbackend shell hostare not controlled by the same setting.
Local artifacts / evidence
Relevant local files:
C:\Users\Administrator\.codex\.sandbox\sandbox.logC:\Users\Administrator\.codex\.sandbox\requests\request-cc3f6e10eba310db9a9eb6e1beb7c306.jsonC:\Users\Administrator\.codex\archived_sessions\rollout-2026-04-24T19-02-17-019dbf27-9db1-7963-9dd0-8c8d732d2f97.jsonlRelevant log pattern:
and repeated failures around:
Request
Please investigate whether the Windows
shell_commandrunner / sandbox host is creating a token or process environment that breaks PowerShell's AppLocker / Safer policy initialization path.From local testing, the issue does not reproduce when the same executable, env, cwd, and command are launched outside the Codex runner.
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Process terminated.
The type initializer for 'System.Management.Automation.Runspaces.InitialSessionState' threw an exception.
at System.Environment.FailFast(System.Runtime.CompilerServices.StackCrawlMarkHandle, System.String, System.Runtime.CompilerServices.ObjectHandleOnStack, System.String)
at System.Environment.FailFast(System.Threading.StackCrawlMark ByRef, System.String, System.Exception, System.String)
at System.Environment.FailFast(System.String, System.Exception)
at Microsoft.PowerShell.UnmanagedPSEntry.Start(System.String[], Int32)
at Microsoft.PowerShell.ManagedPSEntry.Main(System.String[])
System.TypeInitializationException: The type initializer for 'System.Management.Automation.Runspaces.InitialSessionState' threw an exception.
---> System.ComponentModel.Win32Exception (126): 找不到指定的模块。
at System.Management.Automation.Internal.SecuritySupport.GetSaferPolicy(String path, SafeHandle handle)
at System.Management.Automation.Security.SystemPolicy.TestSaferPolicy(String testPathScript, String testPathModule)
at System.Management.Automation.Security.SystemPolicy.GetAppLockerPolicy(String path, SafeHandle handle)
at System.Management.Automation.Security.SystemPolicy.GetLockdownPolicy(String path, SafeHandle handle, Nullable`1 canExecuteResult)
at System.Management.Automation.Security.SystemPolicy.GetLockdownPolicy(String path, SafeHandle handle)
at System.Management.Automation.Security.SystemPolicy.GetSystemLockdownPolicy()
at System.Management.Automation.Runspaces.InitialSessionState..cctor()
--- End of inner exception stack trace ---
at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault2()
at Microsoft.PowerShell.UnmanagedPSEntry.Start(String[] args, Int32 argc)
Right now, my Codex can't use PowerShell to retrieve file contents or execute the corresponding commands, which is really frustrating. I have no choice but to fall back to using
node_replto retrieve file contents. I hope Codex fixes this issue as soon as possible.Codex, I can’t live without you—please fix this as soon as possible. Let me know if you need any other information; I can reliably reproduce the issue on my machine right now.
<img width="238" height="233" alt="Image" src="https://github.com/user-attachments/assets/e1d192c3-4d85-491e-81ec-2935c1ed8063" />
I can't use PowerShell with either the Codex app or the Codex CLI.
Codex -> PowerShell crashes during initialization. However, it works fine on my machine with both PowerShell 5.1 and 7
I have also reported this issue on CodexApp. The issue ID is: 019ddc8d-ff64-7321-9c26-88695c29e5ce