Get OS architecture remotely via PowerShell
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"
}
Related videos on Youtube
Volodymyr Molodets
Updated on September 18, 2022Comments
-
Volodymyr Molodets over 1 year
Does anybody know how to grab OS architecture remotely from multiple Windows hosts via PowerShell?
-
Volodymyr Molodets over 11 yearsPerfect, it works great. Is there a way to grab OS Architecture for 2003 servers the same way?
-
MDMarra over 11 yearsHm, I don't see anything in the
win32_operatingsystem
class properties on 2003 that would work. There might be something inwin32_processor
but I don't have anything handy to test it with. -
MDMarra over 11 yearsThis is an interesting approach, but the OP asked for PowerShell.
-
ThatGraemeGuy over 11 yearsFair 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 over 11 yearsMDMarra, 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 over 11 yearsOK so...... killer Google-fu + a pocket full of common sense = PowerShell version. :-)