本文介绍了Windows Powershell 有时不输出任何值(温度传感器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有时会发生没有温度传感器显示的情况.我使用 Powershell 来读取值并且经常工作.我想知道为什么 Windows 有时不返回任何内容.是在我的笔记本电脑、软件还是什么上?
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
推荐答案
实际的类是 MSAcpi_ThermalZoneTemperature.使用以下函数:
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"
}
替代方案:
$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
}
参考链接:热区信息
希望有帮助.
这篇关于Windows Powershell 有时不输出任何值(温度传感器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!