-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-Temperature.ps1
More file actions
23 lines (22 loc) · 867 Bytes
/
Get-Temperature.ps1
File metadata and controls
23 lines (22 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function Get-Temperature {
$thermalZone = Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi"
$returnTemp = @()
# Process temps
foreach ($temp in $thermalZone.CurrentTemperature) {
$currentTempKelvin = ($temp / 10)
$currentTempCelsius = [math]::round($currentTempKelvin - 273.15)
$currentTempFahrenheit = [math]::round((9 / 5) * $currentTempCelsius + 32)
$returnTemp += "$currentTempCelsius" + " °C | " + "$currentTempFahrenheit" + " °F"
$global:numberOfTemps = ($returnTemp).count
}
foreach ($return in $returnTemp) {
if ($return -ge "50") {
write-host "$return" -ForegroundColor Red
$global:highTemp++
}
else {
write-host "$return" -ForegroundColor Green
$global:lowTemp++
}
}
}