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

Any suggestions?


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



' *** 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)

  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


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.

  • 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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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