Function Check-HyperThreading($ComputerName){
# Get the Processor information for the computer
$Proc = Get-WMIObject Win32_Processor -ComputerName $ComputerName
# Determine if hyper-threading is enabled
$CPUCount = @($Proc).count
$NumberOfLogicalProcessors = $($Proc | measure-object -Property NumberOfLogicalProcessors -sum).Sum
$NumberOfCores = $($Proc | measure-object -Property NumberOfCores -sum).Sum
# Output the results as a PS object
[pscustomobject]@{
Computer = $ComputerName
CPUCount = $CPUCount
NumberOfLogicalProcessors = $NumberOfLogicalProcessors
NumberOfCores = $NumberOfCores
HyperThreading = $($NumberOfLogicalProcessors -gt $NumberOfCores)
}
}
This function will return the process information from a local or remote computer and determine if HyperThreading is enabled. If the number of logical processors is greater than physical processors (cores), then hyperthreading is enabled and the function returns True for HyperThreading.
PS C:\> Function Check-HyperThreading($ComputerName){ >> # Get the Processor information for the computer >> $Proc = Get-WMIObject Win32_Processor -ComputerName $ComputerName >> # Determine if hyper-threading is enabled >> $CPUCount = @($Proc).count >> $NumberOfLogicalProcessors = $($Proc | measure-object -Property NumberOfLogicalProcessors -sum).Sum >> $NumberOfCores = $($Proc | measure-object -Property NumberOfCores -sum).Sum >> # Output the results as a PS object >> [pscustomobject]@{ >> Computer = $ComputerName >> CPUCount = $CPUCount >> NumberOfLogicalProcessors = $NumberOfLogicalProcessors >> NumberOfCores = $NumberOfCores >> HyperThreading = $($NumberOfLogicalProcessors -gt $NumberOfCores) >> } >> } >> >> Check-HyperThreading -ComputerName $env:COMPUTERNAME Computer : MAT-F0CXE4G CPUCount : 1 NumberOfLogicalProcessors : 4 NumberOfCores : 2 HyperThreading : True