?
Solved

Script to query remote 64bit CPU capabililites

Posted on 2009-05-20
13
Medium Priority
?
4,152 Views
Last Modified: 2012-05-07
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!
0
Comment
Question by:AndersBiro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 3
13 Comments
 
LVL 7

Expert Comment

by:Hubasan
ID: 24433179
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

0
 
LVL 41

Expert Comment

by:graye
ID: 24433662
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.
 
0
 
LVL 7

Expert Comment

by:Hubasan
ID: 24434027
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

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:Hubasan
ID: 24434042
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
0
 
LVL 41

Assisted Solution

by:graye
graye earned 200 total points
ID: 24435647
No, that's not gonna do it either... again, the Architecture field of the Win32_Processor class does not show the CPU's capability to support x64...
On my own 32-bit XP SP3 system with an Intel Q9550 CPU (which absolutely supports a 64-bit OS), the Architecture field shows 0 (meaning x86)
0
 
LVL 7

Expert Comment

by:Hubasan
ID: 24435889
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?.
0
 
LVL 41

Expert Comment

by:graye
ID: 24436810
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
0
 
LVL 7

Expert Comment

by:Hubasan
ID: 24441353
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.


0
 

Author Comment

by:AndersBiro
ID: 24450121
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?
0
 

Author Comment

by:AndersBiro
ID: 24451577
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.

0
 

Author Comment

by:AndersBiro
ID: 24451728
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.
0
 
LVL 7

Accepted Solution

by:
Hubasan earned 1800 total points
ID: 24454359
Ok so here is the script that uses chkcpu32 and psexec and gives you results in the prompt.

It can be modified of course to do mass checks but use this for testing:

NOTE: script assumes that both PSEXEC and CHKCPU32 programs are in C:\Windows\System32, and if they are not please put them there.

Test it and let me know:
Set oWS = CreateObject("WScript.Shell")
Set oFS = CreateObject("Scripting.FileSystemObject")
 
sComputer = "ComputerNameHere"
 
sScriptName = WScript.ScriptName
sScriptPath = WScript.ScriptFullName
sTemp = Replace(sScriptName, ".vbs", ".txt")
sTempFile = Replace(sScriptPath, sScriptName, sTemp)
 
oWS.Run "cmd.exe /c psexec \\" & sComputer & " -c C:\Windows\System32\chkcpu32 /v >" & Chr(34) & sTempFile & chr(34),0 ,True
 
Set oTempFile = oFS.OpenTextFile(sTempFile, 1)
 
Do While oTempFile.AtEndOfStream <> True
	sText = oTempFile.ReadLine
		If Instr(sText, "64-bit support") Then
			sText = LCase(sText)
			If InStr(sText, "no") Then
				oWS.Popup "CPU with 64-bit support NOT detected", ,sComputer , vbExclamation
			Else
				oWS.Popup "CPU with 64-bit support DETECTED!", ,sComputer , vbInformation
			End If
        Exit Do
    End If
Loop
 
oTempFile.Close
oFS.DeleteFile(sTempFile)

Open in new window

0
 

Author Comment

by:AndersBiro
ID: 24466321
Hello, it seems to work just fine so I think my issue is completely solved. Thanks a lot!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question