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

44,751

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

So be it:

[System.Environment]::Is64BitOperatingSystem

Solution 3

echo %PROCESSOR_ARCHITECTURE%

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

Solution 5

With PowerShell:

(gwmi win32_computersystem).SystemType

Source: http://www.sysadmit.com/2015/10/windows-como-saber-si-es-de-32-o-64-bits.html

Share:
44,751

Related videos on Youtube

Matt Spradley
Author by

Matt Spradley

Updated on September 17, 2022

Comments

  • Matt Spradley
    Matt Spradley over 1 year

    Using the Powershell console, what command/commands can be executed to determine if the 32 or 64 bit bersion of Windows Server 2008 is installed?

    • Kevin Kuphal
      Kevin Kuphal almost 15 years
      Very similar to this question: serverfault.com/questions/27495/…
    • Kevin Kuphal
      Kevin Kuphal almost 15 years
      I see now you asked both :) The environment variable option given in your other question should be trivial to get from PowerShell.
    • Matt Spradley
      Matt Spradley almost 15 years
      Yes... I wanted a PowerShell solution as well and I decided it was better to break my 2 part question into 2 questions since everyone were only answering the first part.
  • ThatGraemeGuy
    ThatGraemeGuy almost 15 years
    That's not nearly reliable enough, I've seen software that installs to "C:\Program Files (x86)" on 32-bit Windows.
  • Madhu Cheluvaraju
    Madhu Cheluvaraju almost 15 years
    Ehh, true. Someone had already beat me to the best answer, so I figured I'd give the lazy one.
  • Lost Hobbit
    Lost Hobbit over 11 years
    Perhaps because it's the processor architecture, and not the version of Windows?
  • Lost Hobbit
    Lost Hobbit over 11 years
    I believe the question was about the version of Windows, not the processor architecture.
  • John Homer
    John Homer over 8 years
    One-liner: (gwmi win32_operatingsystem).osarchitecture
  • John Homer
    John Homer over 8 years
    Technically, that's .NET reflection...not native powershell. I'll show myself out...
  • John Homer
    John Homer over 8 years
    That's the type of processor, not Windows bitness. More Info:
  • romu
    romu over 8 years
    excellent @JohnHomer !
  • Nathan
    Nathan over 8 years
    I think having this here downvoted is informative—thanks!