Get CPU temperature in CMD/POWER Shell

utkroza blue picture utkroza blue · Sep 28, 2016 · Viewed 69.9k times · Source

In my computer I am trying to get the CPU temperature. Searching on StackOverflow I found this:

C:\WINDOWS\system32>wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature

But I get this error:

Node - ADMIN
ERROR:
Description = Not supported

Answer

saftargholi picture saftargholi · Sep 28, 2016

you can use this code :

function Get-Temperature {
    $t = Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi"
    $returntemp = @()

    foreach ($temp in $t.CurrentTemperature)
    {


    $currentTempKelvin = $temp / 10
    $currentTempCelsius = $currentTempKelvin - 273.15

    $currentTempFahrenheit = (9/5) * $currentTempCelsius + 32

    $returntemp += $currentTempCelsius.ToString() + " C : " + $currentTempFahrenheit.ToString() + " F : " + $currentTempKelvin + "K"  
    }
    return $returntemp
}

Get-Temperature