mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-01-28 16:48:39 +01:00
Update check-battery.ps1
This commit is contained in:
parent
e22c6a7ea8
commit
843c9dbfa1
@ -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" }
|
||||
|
Loading…
Reference in New Issue
Block a user