Windows下统计vCPU个数

2023-05-24 16:04:41 浏览数 (1)

举个具体例子,有台机器

执行msinfo32有2颗CPU,每颗是20个cores(每个core是双线程),即每颗是40个vCPU

代码语言:javascript复制
msinfo32

代码语言:javascript复制
PS C:UsersAdministrator> (Get-WmiObject -Class Win32_Processor).NumberOfLogicalProcessors
40
40
PS C:UsersAdministrator> [System.Environment]::ProcessorCount
40
PS C:UsersAdministrator> [System.Environment]::ProcessorCount * ((Get-WmiObject -Class Win32_Processor).NumberOfLogicalProcessors).count
80
PS C:UsersAdministrator> (Get-WmiObject -Class Win32_ComputerSystem).NumberOfLogicalProcessors
80
PS C:UsersAdministrator> (Get-CimInstance -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors
80
PS C:UsersAdministrator> $ProcessorCount = (Get-CimInstance -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors
PS C:UsersAdministrator> $ProcessorCount
80

代码语言:javascript复制
(Get-CimInstance -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors

0 人点赞