Get CPU temperature in CMD/POWER Shell

后端 未结 5 2000
暖寄归人
暖寄归人 2020-12-18 00:48

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 M         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-18 01:24

    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
    

提交回复
热议问题