Under Review

Live Response: Temperature of a machine

  REVIEWED by Sophos 

In Celsius

--------------------------------------

function Get-Temperature {

$t = Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi"
$returntemp = @()

foreach ($temp in $t.CurrentTemperature)
{


$currentTempKelvin = $temp / 10
$currentTempCelsius = $currentTempKelvin - 273.15

$returntemp += $currentTempCelsius.ToString() + " " + [char]0x00B0 + "C"
}
return $returntemp
}


Get-Temperature

--------------------------------------

 

In Fahrenheit

--------------------------------------

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() + " " + [char]0x00B0 + "C"
}
return $returntemp
}

Get-Temperature

--------------------------------------

Parents Comment Children
No Data