Update check-battery.ps1

This commit is contained in:
Markus Fleschutz 2022-12-04 09:42:15 +01:00
parent e22c6a7ea8
commit 843c9dbfa1

View File

@ -17,10 +17,12 @@ try {
} else {
Add-Type -Assembly System.Windows.Forms
$Details = [System.Windows.Forms.SystemInformation]::PowerStatus
switch ($Details.BatteryChargeStatus) {
"NoSystemBattery" { $BatteryStatus = "No battery" }
"0" { [int]$Life = 100*$Details.BatteryLifePercent; [int]$Remaining = $Details.BatteryLifeRemaining / 60; $BatteryStatus = "Battery $Life%, $Remaining min left" }
default { $BatteryStatus = $Details.BatteryChargeStatus }
if ($Details.BatteryChargeStatus -eq "NoSystemBattery") {
$BatteryStatus = "No battery"
} else {
[int]$Percent = 100*$Details.BatteryLifePercent
[int]$Remaining = $Details.BatteryLifeRemaining / 60
$BatteryStatus = "Battery $Percent%, $Remaining min left"
}
switch ($Details.PowerLineStatus) {
"Online" { $PowerStatus = "plugged in to AC power" }