PowerShell/Scripts/check-cpu-temp.ps1

28 lines
672 B
PowerShell
Raw Normal View History

2021-03-20 16:13:54 +01:00
#!/bin/powershell
<#
2021-03-22 20:10:18 +01:00
.SYNTAX ./check-cpu-temp.ps1
.DESCRIPTION checks the CPU temperature
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
2021-03-20 16:13:54 +01:00
#>
try {
if (test-path "/sys/class/thermal/thermal_zone0/temp") {
$Temp = get-content "/sys/class/thermal/thermal_zone0/temp"
$Temp = $Temp / 1000.0
} else {
2021-03-20 16:35:40 +01:00
write-warning "No CPU temperature available"
2021-03-20 16:13:54 +01:00
exit 0
}
2021-03-20 16:23:49 +01:00
if ($Temp -gt "80") {
write-warning "CPU has $Temp °C!"
} else {
write-host -foregroundColor green "OK - CPU has $Temp °C"
}
2021-03-20 16:13:54 +01:00
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}