install.ps1 Crashes on Windows 10 with PS 5.1

Open 💬 3 comments Opened Apr 25, 2026 by reard3n

What issue are you seeing?

Running install.ps1 on Windows 10 with PS 5.1 results in a crash to the whole install script:

PS C:\users\user\Downloads> .\install.ps1

Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your
computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message. Do you want to run C:\users\user\Downloads\install.ps1?
[D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"): R
The property 'OSArchitecture' cannot be found on this object. Verify that the property exists.
At C:\users\user\Downloads\install.ps1:584 char:1
+ $architecture = [System.Runtime.InteropServices.RuntimeInformation]:: ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : PropertyNotFoundStrict

PS C:\users\user\Downloads>

What steps can reproduce the bug?

Download and run the script on Windows 10, with PS 5.1.X

Get-ComputerInfo | Select-Object WindowsProductName, WindowsVersion, OsHardwareAbstractionLayer
>>

WindowsProductName WindowsVersion OsHardwareAbstractionLayer
------------------ -------------- --------------------------
Windows 10 Pro     2009           10.0.26100.1
$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.26100.8115
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.26100.8115
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Observe this error when executing:

The property 'OSArchitecture' cannot be found on this object. Verify that the property exists.
At C:\users\user\Downloads\install.ps1:584 char:1
+ $architecture = [System.Runtime.InteropServices.RuntimeInformation]:: ...

What is the expected behavior?

The script should function even on older versions of powershell, with graceful fallback to other detection methods.

I've modeled this behavior in this patch:
https://github.com/openai/codex/compare/main...reard3n:codex:installer-bugfix?expand=1

Additional information

_No response_

View original on GitHub ↗

3 Comments

reard3n · 4 months ago

@efrazer-oai - seems like you are the most recent maintainer of this script. I am not a contributor, so I can't open a PR for this patch.

z-a-f · 2 months ago

If you have powershell 7+ installed you can try pwsh:

pwsh -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
epicbugs · 26 days ago
If you have powershell 7+ installed you can try pwsh: pwsh -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"

Unfortunately on some instances of Windows 10 it gets caught and denied by Windows Defender as a possible trojan.