実際のクラスは、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
はそれが役に立てば幸い以下の機能を使用してください。
複数のCPUを持っている場合、 'Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace" root/wmi "は複数のインスタンスを返し、関数は配列を10で除算しようとすると例外をスローします。 –
@LievenKeersmaekers:それでarraylistは仕事をしなければならず、また試してみるべきです:) –