Today I found myself in a situation where I needed to figure out if hyperthreading was enabled (something to do with SQL licensing), on a whole bunch of hosts.
Here’s a section of the code I used. Hope you find it useful 🙂
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# Define variables # Define variables $ComputerName = $env:COMPUTERNAME $LogicalCPU = 0 $PhysicalCPU = 0 $Core = 0 # Get the Processor information from the WMI object $Proc = [object[]]$(get-WMIObject Win32_Processor -ComputerName $ComputerName) #Perform the calculations $Core = $Proc.count $LogicalCPU = $($Proc | measure-object -Property NumberOfLogicalProcessors -sum).Sum $PhysicalCPU = $($Proc | measure-object -Property NumberOfCores -sum).Sum #Build the object $Hash = @{ LogicalCPU = $LogicalCPU PhysicalCPU = $PhysicalCPU CoreNr = $Core HyperThreading = $($LogicalCPU -gt $PhysicalCPU) } #Output the object New-Object -TypeName PSObject -Property $Hash |
Update: Here is a short version that provides a true/false:
1 |
$($Proc | measure-object -Property NumberOfLogicalProcessors -sum).Sum -gt $($Proc | measure-object -Property NumberOfCores -sum).Sum |