Update check-cpu.ps1

This commit is contained in:
Markus Fleschutz 2022-12-12 19:02:32 +01:00
parent 3e80e5cb68
commit e1150b70e0

View File

@ -31,29 +31,32 @@ function GetCPUTemperatureInCelsius {
try {
Write-Progress "Querying CPU details ..."
$Status = ""
$Celsius = GetCPUTemperatureInCelsius
if ($Celsius -eq 99999.9) {
$Temp = "no temp"
} elseif ($Celsius -gt 50) {
$Temp = "⚠️$($Celsius)°C"
$Temp = "$($Celsius)°C"
$Status = ""
} elseif ($Celsius -lt 0) {
$Temp = "⚠️$($Celsius)°C"
$Temp = "$($Celsius)°C"
$Status = ""
} else {
$Temp = "$($Celsius)°C"
}
if ($IsLinux) {
" CPU has $Temp"
"$Status CPU has $Temp"
} else {
$Details = Get-WmiObject -Class Win32_Processor
$CPUName = $Details.Name.trim()
$DeviceID = $Details.DeviceID
$Speed = "$($Details.MaxClockSpeed)MHz"
$Socket = $Details.SocketDesignation
" CPU $CPUName ($DeviceID, $Speed, socket $Socket, $Temp)"
"Status CPU $CPUName ($DeviceID, $Speed, socket $Socket, $Temp)"
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
}