Techibee.com

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…

Exit mobile version