Skip to content

Instantly share code, notes, and snippets.

@bklockwood
Created September 4, 2015 10:53
Show Gist options
  • Save bklockwood/13f6b17eb98e8f4b0a95 to your computer and use it in GitHub Desktop.
Save bklockwood/13f6b17eb98e8f4b0a95 to your computer and use it in GitHub Desktop.
Get-Temperature
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
}
@bklockwood
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment