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

I have been unable to discover a way to determine what processors/CPUs/sockets are present in a PC/Server.

Any suggestions?

share|improve this question

5 Answers 5

The WMI WIN32_Processor class gives basic info about installed processors..

share|improve this answer

Try:

' *** Get the server name

  set wsh_shell = wscript.CreateObject("Wscript.Shell")
  set wsh_env = wsh_shell.Environment("PROCESS")
  server_name =  wsh_env("COMPUTERNAME")
  set wsh_env = nothing
  set wsh_shell = nothing

' *** Open the WMI service

  set wmi_service = GetObject("winmgmts:\\" & server_name)

' *** Processor

  set wmi_objectset = wmi_service.InstancesOf("Win32_Processor")

  for each wmi_object in wmi_objectset
    wscript.echo cstr(wmi_object.MaxClockSpeed) & " - " _
               & cstr(wmi_object.NumberOfCores)
  next

  set wmi_service = nothing

I've had the script print the clock speed, but you can look at any of the properties mention in the link in Stuart Dunkeld's post.

John Rennie

share|improve this answer

In addition to the Win32_Processor class mentioned in other answers, you also have the Win32_ComputerSystem class which has the NumberOfLogicalProcessors and NumberOfProcessors values. The notes in the documentation about OS support for those two values are slightly incorrect. XP does support the NumberOfLogicalProcessors value since SP3. I'm guessing Win2003 will also support it whenever its next service pack is released as well.

share|improve this answer
    
can I ask what results are returned if you call these classes on VMWare. Does it still return you the physical processor info, or the VMWare ones? If it is the virtual ones, do you know of a way to get the physical ones on the machine? –  Ryk Aug 16 '11 at 6:30

On old version of Windows (Win2003, XP SP2 or earlier) Win32_Processor.SocketDesignation always returns 'Proc 1' for a logical processor. This script will work on any version of Windows.

$procs = [object[]]$(get-WMIObject Win32_Processor) # force into array even if only 1
if ($procs[0].NumberOfCores -eq $null) { # old version
  $physCount = new-object hashtable
  $procs |%{$physCount[$_.SocketDesignation] = 1}
  "Physical processors: {0}; Logical processors: {1}" -f $physCount.count, $procs.count
} else { # new version
  "Physical processors: {0}; Logical processors: {1}" -f $procs.count, `
    $($procs|measure-object NumberOfLogicalProcessors -sum).Sum
}
share|improve this answer

Please be aware that on Windows Server 2003, SP1 or SP2 the NumberOfCores property of Win32_Processor is not available unless you installed a hotfix 180973 (for x86 or x64) as outlined in this KB: http://support.microsoft.com/kb/932370 . The same for Windows XP SP2 - see KB: http://support.microsoft.com/kb/936235 There is a link on how to request the hotfix by email at the top of each KB page. This property first appeared on Windows Vista.

share|improve this answer

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.