我试图使用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
你可以使用Open Hardware Monitor命令行工具。OpenHardwareMonitorReport.zip。