How to determine 32 or 64 bit version of Windows Server 2008 using Powershell?

Solution 1:

Or try this:

PS C:\Users\jeffh> $os=Get-WMIObject win32_operatingsystem
PS C:\Users\jeffh> $os.OSArchitecture
64-bit

Found at: http://msgoodies.blogspot.com/2008/05/is-this-powershell-session-32-bit-or-64.html

Solution 2:

echo %PROCESSOR_ARCHITECTURE%


Solution 3:

So be it:

[System.Environment]::Is64BitOperatingSystem

Solution 4:

"echo %PROCESSOR_ARCHITECTURE%" down-voted? Must not be powershelly enough, which is funny if you look at the other examples using WMI and other aliases.

oh well, try this:

($env:PROCESSOR_ARCHITECTURE -eq "AMD64")

EDIT - pointed out in the comment that this is not the version of windows, it's the arch. FWIW- It's not the "real" arch, it's what WOW64 is reporting to the app. But you are right... if it's x32 powershell, it'll say x86. Often times this will get you what you want but...

Either way, http://support.microsoft.com/kb/556009 is the registry location to the correct value, and here's a script.

Get-ChildItem HKLM:\HARDWARE\DESCRIPTION\System\CentralProcessor\ | Get-ItemProperty -Name Identifier | Select-Object -Property PSChildName,Identifier | ft -AutoSize