≡ Menu

PowerShell: Get CPU architecture on windows 7 computer

I wrote on the similar topic before. My earlier attempt was to determine OS architecture but this time, I am going to talk about querying CPU architecture using powershell code. It is needless to explain the difference between these two things. 🙂

So, below is the code which helps you determine CPU architecture of a computer.

function Get-CPUArchitecture {
if (($ENV:Processor_Architecture -eq "x86" -and (test-path env:PROCESSOR_ARCHITEW6432)) -or ($ENV:Processor_Architecture -eq "AMD64")) {
write-host "Detected 64-bit CPU architecture"
} elseif ($ENV:Processor_Architecture -eq 'x86') {
write-host "Detected 32-bit CPU architecture"
} else {
write-host "Unable to determine CPU architecture"

Hope this helps…

Comments on this entry are closed.

  • Sitaram Pamarthi June 30, 2011, 12:11 am

    We have another easy way around to check if CPU architecture is 32-bit or 64-bit.
    You can simply use Test-32bit and Test-64bit cmdlets of PowerShellPack module. These won’t take any parameter and will return true or false based the architecture.

    Import-Module powershellpack

  • Robert March 3, 2013, 6:50 am

    With Powershell 3.0 you just need to type “GetCPUArchitecture”