2

From time to time it happens that no temperature sensors are displayed. I use Powershell to read the values and that works often. I would like to know why Windows sometimes does not return anything. Is that on my laptop, software or what?

powershell Get-WmiObject -Class Win32_PerfFormattedData_Counters_ThermalZoneInformation |Select-Object Name,Temperature
Wiffzack
  • 315
  • 3
  • 10

3 Answers3

4

The actual class is MSAcpi_ThermalZoneTemperature. Use the below function:

function Get-Temperature {
    $t = Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi"
    $currentTempKelvin = $t.CurrentTemperature / 10
    $currentTempCelsius = $currentTempKelvin - 273.15
    $currentTempFahrenheit = (9/5) * $currentTempCelsius + 32
    return $currentTempCelsius.ToString() + " C : " + $currentTempFahrenheit.ToString() + " F : " + $currentTempKelvin + "K" 
}

Alternative:

$strComputer = "."

$objWMi = get-wmiobject -namespace root\WMI -computername localhost -Query "Select * from MSAcpi_ThermalZoneTemperature"

foreach ($obj in $objWmi)
{
    write-host "Active:" $obj.Active
    write-host "ActiveTripPoint:" $obj.ActiveTripPoint
    write-host "ActiveTripPointCount:" $obj.ActiveTripPointCount
    write-host "CriticalTripPoint:" $obj.CriticalTripPoint
    write-host "CurrentTemperature:" $obj.CurrentTemperature
    write-host "InstanceName:" $obj.InstanceName
    write-host "PassiveTripPoint:" $obj.PassiveTripPoint
    write-host "Reserved:" $obj.Reserved
    write-host "SamplingPeriod:" $obj.SamplingPeriod
    write-host "ThermalConstant1:" $obj.ThermalConstant1
    write-host "ThermalConstant2:" $obj.ThermalConstant2
    write-host "ThermalStamp:" $obj.ThermalStamp
    write-host
    write-host "########"
    write-host
}

Reference link : Thermal Zone Info

Hope it helps.

Alexander Sinno
  • 554
  • 5
  • 24
Ranadip Dutta
  • 8,857
  • 3
  • 29
  • 45
  • 2
    If you have multiple CPU's, `Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi"` returns multiple instances and your function throws an exception trying to divide an array by 10. Other than that, very good to know, thanks. – Lieven Keersmaekers Jan 23 '17 at 07:17
  • @LievenKeersmaekers: Then arraylist should do the work and also with try catch :) – Ranadip Dutta Jan 23 '17 at 10:17
0

For some reason windows doesn't always return the CPU value for MSAcpi_ThermalZoneTemperature an alternative is to use Open Hardware Monitor Report Get CPU temperature in CMD/POWER Shell

uak
  • 183
  • 3
  • 9
0
powershell Get-CimInstance Win32_PerfFormattedData_Counters_ThermalZoneInformation | findstr /i "Name Temperature"

Windows don't "return" value because OEM decided their sensors won't cooperate with windows wmi(in short).

Start > Run or WinKey+R wmimgmt.msc (and then press [Enter])

PS. - cmd

wmic /namespace:\\root\wmi PATH MSAcpi
Bussller
  • 1,961
  • 6
  • 36
  • 50