如何在PowerShell 5.1版本中获得CPU温度?

时间:2017-08-16 22:55:20

标签: powershell cpu temperature

我试图通过在底部运行以下代码来使用Windows Powershell 5.1来获取CPU温度,但不幸的是我的Powershell没有返回任何内容。我想知道我应该在Windows Powershell 5.1版本中添加什么代码才能获得CPU温度。

我在Windows Powershell 5.1版本中用于获取CPU温度的代码:

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

1 个答案:

答案 0 :(得分:1)

您可以使用“打开硬件监视器”命令行工具。 OpenHardwareMonitorReport.zip

更多信息在这里:https://superuser.com/a/1547638/589805