A step-by-step guide to setting up OpenAI's Codex CLI natively on Windows with PowerShell, VS Code, Git, and GitHub CLI. Go from a Windows machine to running AI-assisted code in under an hour, with no WSL required.

OpenAI's Windows documentation says to use the native Windows sandbox by default. You install Codex in PowerShell, run it against projects on your normal Windows drive, and keep using the Windows tools you already have. There is no Linux distribution to install and no second filesystem to manage.
Codex enforces its sandbox on Windows itself. The sandbox applies the active filesystem and network permissions to every command Codex runs and to the child processes those commands start. Approval policy is a separate control: it decides when Codex stops to ask before using more access.
Choose WSL instead when you need Linux-native tooling, when your repositories and workflow already live in WSL2, or when the native sandbox options do not fit your machine. We cover that route in our Codex CLI on Windows with WSL guide.
By the end of this guide you will have:
Total time: under an hour on a modern machine with a decent connection.
This is the PowerShell companion to our WSL guide, so Steps 1 to 5 follow the same order and the two read as a set.
winget available. If winget --version fails in PowerShell, update Windows or install the Windows Package Manager firstCheck winget now:
winget --version
Already have VS Code? Skip to Step 2.
You can install it from https://code.visualstudio.com, or from PowerShell:
winget install --id Microsoft.VisualStudioCode -e
If you use the website installer, run it with the defaults and, on Select Additional Tasks, check Add to PATH so code . works from any terminal. Launch VS Code once so it finishes first-run setup, then close and reopen PowerShell so the PATH change takes effect.
Tip: Pin VS Code to your taskbar. You will open it constantly.
Unlike the WSL route, there is no Linux layer to install here. This step makes sure your shell and package manager are ready.
Search for Windows Terminal or PowerShell in the Start menu and open it. A normal (non-admin) window is what you want for everything in this guide, including running Codex. Administrator rights are only needed if Codex asks to set up its sandbox in Step 6.
winget --version
You should see a version number. If the command is not found, update Windows or install the Windows Package Manager, then reopen PowerShell.
winget search --id Microsoft.VisualStudioCode -e
winget search --id Git.Git -e
winget search --id GitHub.cli -e
winget search --id OpenJS.NodeJS.LTS -e
Each command should return one exact match.
[System.Environment]::OSVersion.Version
Build 26100 or later means Windows 11 24H2 or newer, which supports Codex's recommended sandbox (more on that in Step 6). Older builds still work using a fallback sandbox.
Terminal: Select Default Profile.New terminals (Ctrl + backtick) now open in PowerShell with a prompt like:
PS C:\Users\yourname>
If you see a different shell, such as Command Prompt or Git Bash, repeat the steps.
Tip: Type code . in any folder from PowerShell and VS Code opens that folder.
Already have a GitHub account? Skip to Step 5. Use the same account you use for work or personal projects. There is no need to create a new one.
If you do not have one yet:
winget install --id Git.Git -e
winget install --id GitHub.cli -e
Close and reopen PowerShell so both commands are on your PATH, then configure your identity and sign in:
git config --global user.name "Your Name"
git config --global user.email "your-github-email@example.com"
gh auth login
Use the email address already registered to your GitHub account for user.email.
If git config --global user.name already returns your correct name, you can skip both git config lines.
At the prompts choose GitHub.com, HTTPS, and Login with a web browser. Copy the one-time code, open the URL, paste it, and authorize. Then verify:
git --version
gh --version
gh auth status
All three should return versions or a confirmed login with no errors.
Codex is OpenAI's coding agent for the terminal. You describe a task in plain language and it reads, edits, and runs code in your project, asking for approval at the boundaries you set.
Download the PowerShell installer, then run it. The -ExecutionPolicy Bypass flag applies to this one script run only and does not change your system policy:
Invoke-WebRequest -UseBasicParsing -Uri 'https://chatgpt.com/codex/install.ps1' -OutFile '.\codex-install.ps1'
powershell -ExecutionPolicy Bypass -File .\codex-install.ps1
OpenAI's Windows deployment docs confirm this installer defaults to latest when you do not pass -Release. Use -Release only when you need to pin a specific version for managed rollout.
Close and reopen PowerShell, then verify as your normal user, not as administrator:
Get-Command codex
codex --version
Get-Command codex should print a path, and codex --version should print a version number. If you see "not recognized", reopen PowerShell once more and confirm you ran the installer in PowerShell, not in a WSL shell.
You can delete codex-install.ps1 afterward.
Use this path if your team standardizes CLI installs through npm. It needs Node.js and npm on the machine first:
winget install --id OpenJS.NodeJS.LTS -e
Reopen PowerShell, then check and install:
node --version
npm --version
npm install -g @openai/codex
codex --version
On Windows, npm installs global packages into your own profile folder by default, so there is no sudo step and no need to change the npm prefix. This is simpler than the Linux route.
Choose how to authenticate:
codex login
codex login --device-auth and enter the one-time code.$secureKey = Read-Host 'OpenAI API key' -AsSecureString
$plainKey = [System.Net.NetworkCredential]::new('', $secureKey).Password
$plainKey | codex login --with-api-key
Remove-Variable plainKey, secureKey
Never put a key in a repository, an AGENTS.md, a script, or a prompt. Confirm either method worked with codex login status.
The first time Codex runs commands on Windows, it uses one of three sandbox implementations:
If Codex shows a Set up Agent sandbox to continue prompt, approve the administrator (UAC) prompt that follows. This setup prompt appears when Codex must provision the legacy elevated sandbox.
To prefer mxc on a compatible machine, or to pin a fallback, add this to $HOME\.codex\config.toml:
[features]
prefer_mxc = true
[windows]
sandbox = "elevated"
Use only the settings you need. sandbox accepts "elevated" or "unelevated". Inside a Codex session, /status and /debug-config show which settings are active.
New-Item -ItemType Directory -Force -Path "$HOME\git\helloworld" | Out-Null
Set-Location "$HOME\git\helloworld"
git init
codex
Codex starts in its default approval mode, so it will ask before doing anything outside the workspace. Type:
Build me a simple Hello World web app with HTML, CSS, and JavaScript. Give it a clean modern look with a centered card, a heading that says 'Hello World', a subtitle with today's date, and a button that shows an alert when clicked. Save everything in this folder.
Approve the file writes as they come up. When it finishes, run /quit.
From the same folder in PowerShell:
Start-Process .\index.html
Your default browser opens the page.
Run this command in a normal PowerShell window:
codex update
Set-Location "$HOME\git"
code .
VS Code opens with your git folder, and Explorer shows helloworld with the files Codex created. The integrated terminal opens in PowerShell, so you can edit, test, and commit without leaving the editor.
Keep projects in a normal folder in your user profile. A path such as C:\Users\yourname\git\my-app works well. Do not move a repository after Codex has set up its sandbox for it, because sandboxing can stop working after a move. If that happens, restart Codex or re-run the sandbox setup.
Watch for the "writable by Everyone" warning. Codex warns when a folder is writable by the Everyone group. Remove that access where appropriate, then restart Codex or re-run the sandbox setup.
Match the approval mode to the risk. Sandbox mode sets what Codex is allowed to touch. Approval policy sets when it must ask. Two settings cover most work:
# Normal development: edit inside the workspace, ask before crossing it
codex --sandbox workspace-write --ask-for-approval on-request
# Investigation and review: no edits
codex --sandbox read-only --ask-for-approval on-request
You can also switch mid-session with /permissions.
Know when full access is fine and when it is not. Full access (--yolo, or --dangerously-bypass-approvals-and-sandbox) means Codex is not limited to your project directory and might perform unintentional destructive actions. It is reasonable in a disposable environment you can throw away, such as a scratch VM or a throwaway learning project. It is the wrong choice on a shared repository, a codebase with credentials nearby, or anything you cannot rebuild. For those, stay on workspace-write with on-request approval so you keep oversight.
--full-auto is not a current Codex flag in codex --help (verified with Codex CLI 0.139.0 on November 1, 2026), so do not rely on it in scripts.
Use /plan before non-trivial changes. Type /plan followed by your request. Codex investigates and proposes an approach without implementing it. Reviewing the plan takes a minute and prevents unwanted changes. Entering Plan mode does not grant write access, and permissions are a separate setting.
Use AGENTS.md as the counterpart to CLAUDE.md. Run /init inside Codex to create a starter AGENTS.md, then edit it. Record build and test commands, conventions, and what Codex must not change. Commit it so the whole team shares the rules. Keep it short, because those tokens load on every task. If your team also uses Claude Code, the same facts belong in both files.
Keep sessions short. Every file read, test log, and message consumes context. Run /status to see usage, /compact to summarize earlier conversation, and /new when the next job is unrelated. Small, focused sessions beat marathon ones. Restate any critical constraint after a compact.
Review before you commit. Run /diff, then /review for a second pass, then run your own tests and check git status.
Check your plan or billing. ChatGPT sign-in follows your plan's limits. API-key sign-in bills per token at platform.openai.com.
This guide was updated against official docs and CLI help on November 1, 2026:
install.ps1 defaults to latest when -Release is omitted.prefer_mxc, and [windows].sandbox keys.codex --help and codex login --help confirm --sandbox, --ask-for-approval on-request, --yolo, codex login --device-auth, codex login --with-api-key, codex login status, and codex update.For teams looking to bring agentic AI into enterprise workflows with HITL controls, private-by-architecture deployment, and outcome-based contracts, talk to the lowtouch.ai team.
About the Author

Rejith Krishnan
Founder and CEO
Rejith Krishnan is the Founder and CEO of lowtouch.ai, a platform dedicated to empowering enterprises with private, no-code AI agents. With expertise in Site Reliability Engineering (SRE), Kubernetes, and AI systems architecture, he is passionate about simplifying the adoption of AI-driven automation to transform business operations.
Rejith specializes in deploying Large Language Models (LLMs) and building intelligent agents that automate workflows, enhance customer experiences, and optimize IT processes, all while ensuring data privacy and security. His mission is to help businesses unlock the full potential of enterprise AI with seamless, scalable, and secure solutions that fit their unique needs.