Add check-cpu-temp.ps1

This commit is contained in:
Markus Fleschutz
2021-03-20 16:13:54 +01:00
parent 85d3137b14
commit 1fc4d5af0e
6 changed files with 32 additions and 3 deletions

23
Scripts/check-cpu-temp.ps1 Executable file
View File

@ -0,0 +1,23 @@
#!/bin/powershell
<#
.SYNTAX ./check-cpu-temp.ps1
.DESCRIPTION checks the CPU temperature
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
try {
if (test-path "/sys/class/thermal/thermal_zone0/temp") {
$Temp = get-content "/sys/class/thermal/thermal_zone0/temp"
$Temp = $Temp / 1000.0
} else {
write-warning "No CPU temperature retrieved"
exit 0
}
write-host -foregroundColor green "OK - CPU has $Temp °C"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}