Link to home
Start Free TrialLog in
Avatar of AndersBiro
AndersBiroFlag for Sweden

asked on

Script to query remote 64bit CPU capabililites

Hello, I need to examine the CPU 64bit capabilities of quite a few servers/clients of mostly unknown configurations to see whether they qualify for 64-bit OS and it is of course possible to log in to every one of them and execute a CPU-detection utility  but that is quite cumbersome and time consuming indeed.
I wonder if it is possible to script this task with VBSCript/Powershell in order to simply query remote computer names, all computers are running Windows so WMI is an option but so far I have not found a WMI class that reveals the CPU 64-bit capabilities? Thanks in advance!
Avatar of Hubasan
Hubasan
Flag of United States of America image

Here is something you can use to test the solution with:

VB script below will prompt you for computer name to go and test if it's x86 or AMD64...it actually looks to registry value called "PROCESSOR_ARCHITECTURE" that is found here:

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

This is just proof of concept and if you want this integrated in mass scan of computers you have to tell me where those computer names will come from?

1) if from a file, then what format is that file going to be in? CSV....one computerName per line...etc

2) if not a file, then do you want to scan all the Servers and Workstations in your Active Directory and produce a log file with the value of this key from each of them? If so, do you have access to all these PC's, so that when you execute this script it will be able to access this reg key on all of them?

Let me know. :-)
Const HKLM = &H80000002
 
Set oNet = CreateObject("WScript.Network")
Set oWS = CreateObject("WScript.Shell")
 
sLocalPC = oNet.ComputerName
sComputer = InputBox("Please enter Computer Name of the computer you wish to check for 64bit compatibility.", "Verify 64bit compatibility", sLocalPC)
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    sComputer & "\root\default:StdRegProv")
 
sKeyPath = "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
sValueName = "PROCESSOR_ARCHITECTURE"
 
oReg.GetStringValue HKLM,sKeyPath,sValueName,sValue
 
oWS.Popup "Computer " & sComputerName & " is: " & sValue & " compatible"

Open in new window

The script above will probably not give you what you want...   The PROCESSOR_ARCHITECTURE is really just an indication of the "bit-ness" of the currently installed OS.   It is not an indicator of whether or not a CPU is actually cabable of running at 64-bits.
However the PROCESSOR_ARCHITECTURE key will give you information that you could look up to verify x64 support.   You'd have to poke around the Intel/AMD site to match the model numbers.
On the other hand, practically every processor sold in the last few years has been 64-bit capable, so I doubt you'll find any that are not.
 
Hi graye and thanks for your comments.

The only reason I used this registry key is because this article here:

http://support.microsoft.com/kb/556009

It's said that this key will actually give you the Architecture of your processor and didn't mention this having anything to do with the OS itself.

However if this is not so, and knowing Microsoft, who knows?, here is a better script that looks to Win32_Processor class to query the processor architecture:

AndersBiro,
You can use script below for testing :-)

Set oNet = CreateObject("WScript.Network")
Set oWS = CreateObject("WScript.Shell")
 
sLocalPC = oNet.ComputerName
sComputer = InputBox("Please enter Computer Name of the computer you wish to check for 64bit compatibility.", "Verify 64bit compatibility", sLocalPC)
 
Set oWMI = GetObject("winmgmts:\\" & sComputer & "\root\cimv2")
Set colItems = oWMI.ExecQuery("Select * from Win32_Processor")
For Each oItem in colItems    
    sArchitecture = oItem.Architecture    
Next
 
Select Case sArchitecture
    Case 0
    	sProcessorType = "x86"
    Case 1
    	sProcessorType = "MIPS"
    Case 2
    	sProcessorType = "Alpha"
    Case 3
    	sProcessorType = "PowerPC"
    Case 6
    	sProcessorType = "Intel Itanium Processor Family (IPF)"
    Case 9
    	sProcessorType = "x64"
    Case Else
    	sProcessorType = "Unknown"
End Select
 
oWS.Popup "Computer " & sComputer & " has: " & Chr(34) & sProcessorType & chr(34) & " processor type"

Open in new window

Oh yeah,

Script above was constructed based on Win32_Processor class and you can find the explanation of it here:

http://msdn.microsoft.com/en-us/library/aa394373.aspx
SOLUTION
Avatar of graye
graye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wow, you are absolutely right. I just tested on the same processor Q9550 and my Dev 32bit XP box and I got the same result.

It seems that this WMI class is not querying the processor at all but the OS. How typical microsoft.

Thanks for stepping in graye,

So since none of these are working, do you have any solution for this user?.
Well, the brute force way is to get the Processor Name via WMI (or via the registry like your first example).   Then you'd have to manually look up the processor on the Intel/AMD website to see if it supports 64-bit
Hi AndersBiro and graye,

Well... as graye pointed out, Win32_Processor class doesn't supply correct information about the processor architecture in Windows XP SPx or any previous version of windows, however I just learned that this was fixed in Vista and upcoming Windows 7 as well as Windows Server 2008.

You can read full information here:
http://www.microsoft.com/technet/scriptcenter/topics/vista/wmi2.mspx

I'm sorry but it seems that the brute force way that graye described is the only way to do it in Windows XP and earlier OS'es.


Avatar of AndersBiro

ASKER

This is rather unfortunate since I deal with WinXP/Win2003 environments only but I suppose one possibility could be to execute a 64-bit check remotely with Sysinternals psexec utility but in order to parse the results the tool must be a command-line utility.
So far I have seen plenty of Windows diagnostic tools  for 64-bit check but no command line utility but it certainly must exist?
As a matter of fact I found this utility http://web.inter.nl.net/hcc/J.Steunebrink/chkcpu.htm which in verbose mode reports 64 bit support as well.
I have however had some problems implementing it using "psexec \\remote -c chkcpu32 /v" which somehow just generate output with XP machines but not Windows servers? I am not very familiar with psexec so perhaps there are some extra security settings that prevent the usage with Windows Servers or perhaps there are better alternatives than psexec for this task?

Basically what I just had in mind was to remotely execute "chkcpu32 /v" and parse the output for the "64-bit support" line.

I just found out that this is an issue with the current version of psexec (1.95) and it now works using a previous version instead so what would be really handy now is a simple way to parse the generated example output below from vbscript in a grep-like manner since only the 64-bit flag is of interest.

C:\Public>psexec \\remote -c chkcpu32 /v

PsExec v1.72 - Execute processes remotely
Copyright (C) 2001-2006 Mark Russinovich
Sysinternals - www.sysinternals.com



 CPU Identification utility v2.04                 (c) 1997-2009 Jan Steunebrink
 
 CPU Vendor and Model: Intel Xeon Dual-Core 5110-5160 B2-step
 Internal CPU speed  : 2328.0 MHz
 Number of CPUs      : 4
 CPU-ID Vendor string: GenuineIntel
 CPU-ID Name string  : Intel(R) Xeon(R) CPU            5140  @ 2.33GHz
 CPU-ID Signature    : 0006F6
 CPU Features        : Floating-Point Unit on chip: Yes
                       Time Stamp Counter         : Yes
                       MMX instruction set        : Yes
                       3DNow! instruction set     : No
                       Streaming SIMD Extensions  : Yes
                       SSE2 support               : Yes
                       SSE3 support               : Yes
                       Hyper-Threading Technology : No
                       Execute Disable protection : Yes
                       64-bit support             : Yes
                       Virtualization Technology  : Yes
 Size of L1 cache    : 64 KB
 Integrated L2 cache : 4096 KB
 Integrated L3 cache : None
chkcpu32.exe exited on danny with error code 0.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello, it seems to work just fine so I think my issue is completely solved. Thanks a lot!