通过WMI确定CPU处理器与套接字

我一直无法find确定PC /服务器中存在哪些处理器/ CPU /sockets的方法。

有什么build议么?

WMI WIN32_Processor类提供有关已安装处理器的基本信息。

尝试:

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

我已经有脚本打印时钟速度,但你可以看看在斯图尔特邓凯尔德的post链接中提到的任何属性。

约翰·雷尼

除了其他答案中提到的Win32_Processor类之外,还有具有NumberOfLogicalProcessors和NumberOfProcessors值的Win32_ComputerSystem类。 有关操作系统支持这两个值的文档中的说明略有不正确。 XP不支持自SP3以来的NumberOfLogicalProcessors值。 我猜Win2003也会支持它,每当它的下一个服务包发布。

在旧版本的Windows(Win2003,XP SP2或更早版本)上,Win32_Processor.SocketDesign总是为逻辑处理器返回“Proc 1”。 这个脚本可以在任何版本的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 } 

请注意,在Windows Server 2003,SP1或SP2上,Win32_Processor的NumberOfCores属性不可用,除非您安装了此KB中列出的修补程序180973(适用于x86或x64): http : //support.microsoft.com/kb/zh-cn/ 932370 。 对于Windows XP SP2也是如此 – 请参阅知识库: http : //support.microsoft.com/kb/936235有关如何通过电子邮件在每个KB页面顶部请求修补程序的链接。 此属性首先出现在Windows Vista上。