Windows Powershell有时不会输出任何值(温度传感器)

时间:2017-01-22 14:24:25

标签: windows powershell

有时不会显示温度传感器。我使用Powershell来读取值并且经常有效。我想知道为什么Windows有时不会返回任何内容。这是在我的笔记本电脑,软件或什么?

powershell Get-WmiObject -Class Win32_PerfFormattedData_Counters_ThermalZoneInformation |Select-Object Name,Temperature

3 个答案:

答案 0 :(得分:4)

实际的课程是 MSAcpi_ThermalZoneTemperature 。使用以下功能:

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
}

参考链接:Thermal Zone Info

希望它有所帮助。

答案 1 :(得分:0)

由于某些原因,Windows并不总是返回len is 5 #that is OK foo idn=a b c d e n=1 #should be 5 的CPU值,另一种方法是使用“打开硬件监视器报告” Get CPU temperature in CMD/POWER Shell

答案 2 :(得分:0)

powershell Get-CimInstance Win32_PerfFormattedData_Counters_ThermalZoneInformation | findstr /i "Name Temperature"

Windows不会“返回”值,因为OEM决定其传感器无法与Windows wmi(简称Windows)配合使用。

开始>运行或WinKey + R wmimgmt.msc(然后按[Enter])

PS。 -cmd

wmic /namespace:\\root\wmi PATH MSAcpi