Skip to content

Instantly share code, notes, and snippets.

@Trimad
Created June 1, 2022 12:58
Show Gist options
  • Save Trimad/56bf37dc6769cdd3fc12ae7be62f3049 to your computer and use it in GitHub Desktop.
Save Trimad/56bf37dc6769cdd3fc12ae7be62f3049 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment