Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

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

share|improve this answer
    
Perfect, it works great. Is there a way to grab OS Architecture for 2003 servers the same way? –  Volodymyr Oct 15 '12 at 13:48
    
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 Oct 15 '12 at 13:52
    
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 –  Volodymyr Oct 16 '12 at 6:43
    
You know you can run that second PowerShell command against a 2003 machine remotely even if it doesn't have PowerShell installed, right? No need to mess with the voodoo black magic known as wmic :) –  MDMarra Oct 16 '12 at 10:58
add comment

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|improve this answer
    
This is an interesting approach, but the OP asked for PowerShell. –  MDMarra Oct 15 '12 at 14:25
    
Fair enough, I figured that was simple enough to be translated to PowerShell by someone who is sufficiently familiar with it. I'm not. –  ThatGraemeGuy Oct 16 '12 at 6:35
    
OK so...... killer Google-fu + a pocket full of common sense = PowerShell version. :-) –  ThatGraemeGuy Oct 16 '12 at 6:49
add comment

This works for me

PS > $env:processor_architecture
AMD64

PowerShell 32-bit or 64-bit

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.