mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-22 18:08:18 +02:00
Update check-cpu.ps1
This commit is contained in:
parent
f76872ca9e
commit
d261f1efdd
@ -30,20 +30,19 @@ function GetCPUTemperatureInCelsius {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$Temp = GetCPUTemperatureInCelsius
|
$Details = Get-WmiObject -Class Win32_Processor
|
||||||
if ($Temp -eq 99999.9) {
|
$DeviceName = $Details.Name.trim()
|
||||||
"⚠️ CPU temperature query is unsupported."
|
$Celsius = GetCPUTemperatureInCelsius
|
||||||
} elseif ($Temp -gt 80) {
|
if ($Celsius -eq 99999.9) {
|
||||||
"⚠️ CPU is too hot at $($Temp)°C!"
|
$Temp = "no temperature"
|
||||||
} elseif ($Temp -gt 50) {
|
} elseif ($Celsius -gt 50) {
|
||||||
"✅ CPU is $($Temp)°C hot."
|
$Temp = "$($Celsius)°C hot"
|
||||||
} elseif ($Temp -gt 0) {
|
} elseif ($Celsius -gt 0) {
|
||||||
"✅ CPU is $($Temp)°C warm."
|
$Temp = "$($Celsius)°C warm"
|
||||||
} elseif ($Temp -gt -20) {
|
|
||||||
"✅ CPU is $($Temp)°C cold."
|
|
||||||
} else {
|
} else {
|
||||||
"⚠️ CPU is too cold at $($Temp)°C!"
|
$Temp = "$($Celsius)°C cold"
|
||||||
}
|
}
|
||||||
|
"✅ $DeviceName ($($Details.DeviceID), $($Details.MaxClockSpeed)MHz, $Temp)"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user