Get OS architecture remotely via PowerShell

14,193

Solution 1

get-wmiobject win32_operatingsystem -computer $_ | select-object OSArchitecture

You'll pipeline the list of computer names into this command so that $_ is interpreted as each computer in your list.


Edit: After doing some digging, it appears that this will work on both 2003 and 2008.

get-wmiobject win32_computersystem -computer $_ | select-object systemtype

Solution 2

For Windows XP/2003 and up, Win32_Processor has an AddressWidth property which will be 32 or 64, as appropriate.

There's 1 WMI object instance of class Win32_Processor for each CPU known to Windows' Device Manager, so I've typically done this sort of thing in the past. It's VBScript, my PowerShell sucks, but you get the idea...

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor WHERE AddressWidth='64'")
If colItems.Count = 0 Then
    strArch = "x86"
Else
    strArch = "x64"
End If

update: translated to PowerShell:

If ($(Get-WmiObject -Query "SELECT * FROM Win32_Processor WHERE AddressWidth='64'")) {
    Write-Host "I'm x64"
} Else {
    Write-Host "I'm x86"
}
Share:
14,193

Related videos on Youtube

Volodymyr Molodets
Author by

Volodymyr Molodets

Updated on September 18, 2022

Comments

  • Volodymyr Molodets
    Volodymyr Molodets over 1 year

    Does anybody know how to grab OS architecture remotely from multiple Windows hosts via PowerShell?

  • Volodymyr Molodets
    Volodymyr Molodets over 11 years
    Perfect, it works great. Is there a way to grab OS Architecture for 2003 servers the same way?
  • MDMarra
    MDMarra over 11 years
    Hm, I don't see anything in the win32_operatingsystem class properties on 2003 that would work. There might be something in win32_processor but I don't have anything handy to test it with.
  • MDMarra
    MDMarra over 11 years
    This is an interesting approach, but the OP asked for PowerShell.
  • ThatGraemeGuy
    ThatGraemeGuy over 11 years
    Fair enough, I figured that was simple enough to be translated to PowerShell by someone who is sufficiently familiar with it. I'm not.
  • Volodymyr Molodets
    Volodymyr Molodets over 11 years
    MDMarra, this is great! Thx for sharing this, that's really hepful. I've start digging into WMIC to get this info for Windows Server 2003 machines. Something like WMIC /NODE:"TESTSERVER1","TESTSERVER2",@"C:\COMPUTERLIST.TXT" cpu get DataWidth /format:list
  • ThatGraemeGuy
    ThatGraemeGuy over 11 years
    OK so...... killer Google-fu + a pocket full of common sense = PowerShell version. :-)