Wiffzack
Wiffzack

Reputation: 345

Windows Powershell sometimes outputs no values (temperature sensor)

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

Upvotes: 2

Views: 1100

Answers (3)

Danijel
Danijel

Reputation: 1

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

Upvotes: 0

uak
uak

Reputation: 333

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

Upvotes: 0

Ranadip Dutta
Ranadip Dutta

Reputation: 9173

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.

Upvotes: 4

Related Questions