Update check-cpu.ps1

This commit is contained in:
Markus Fleschutz
2022-05-31 14:38:34 +02:00
committed by GitHub
parent dfad9e5084
commit af18ccd73b

View File

@ -2,14 +2,14 @@
.SYNOPSIS .SYNOPSIS
Checks the CPU temperature Checks the CPU temperature
.DESCRIPTION .DESCRIPTION
This PowerShell script checks the CPU temperature. This PowerShell script queries the CPU temperature and returns it.
.EXAMPLE .EXAMPLE
PS> ./check-cpu PS> ./check-cpu
✔️ CPU has 30.3 °C CPU is 30.3 °C warm.
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
Author: Markus Fleschutz / License: CC0 Author: Markus Fleschutz | License: CC0
#> #>
try { try {
@ -21,7 +21,6 @@ try {
$Temp = @($data)[0].HighPrecisionTemperature $Temp = @($data)[0].HighPrecisionTemperature
$Temp = [math]::round($Temp / 100.0, 1) $Temp = [math]::round($Temp / 100.0, 1)
} }
if ($Temp -gt 80) { if ($Temp -gt 80) {
$Reply = "CPU is $($Temp)°C extremely hot!" $Reply = "CPU is $($Temp)°C extremely hot!"
} elseif ($Temp -gt 50) { } elseif ($Temp -gt 50) {
@ -33,8 +32,7 @@ try {
} else { } else {
$Reply = "CPU is $($Temp)°C extremely cold!" $Reply = "CPU is $($Temp)°C extremely cold!"
} }
& "$PSScriptRoot/give-reply.ps1" $Reply
& "$PSScriptRoot/give-reply.ps1" "$Reply"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"