举个具体例子,有台机器
执行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