≡ Menu

Hey PowerShell, What is my laptop battery status?

Yesterday I wrote about different ways to check how much charge is left in the laptop battery. After that I explored win32_battery WMI class further and got some more useful information.

How do you know your battery current status, like is it charging properly?, is it running low, it is full with charge, it is partially charged, is the charge is too low?. It is easy to answer this kind of questions if you can interpret batterystatus attribute of Win32_Battery WMI class. Let us see the possible values this attribute can hold and their meaning.

Value Meaning

1
The battery is discharging.

2
The system has access to AC so no battery is being discharged. However, the battery is not necessarily charging.

3
Fully Charged

4
Low

5
Critical

6
Charging

7
Charging and High

8
Charging and Low

9
Charging and Critical

10
Undefined

11
Partially Charged

*Above table is copied from MSDN site.

Now let us write a script to check the battery current status.

Function Check-BatteryState {
param($Laptop=$env:computername)
$Bstatus = (Get-WmiObject -Class Win32_Battery -ea 0).BatteryStatus
if($Bstatus) {
    switch ($Bstatus)
    {
    1 { "Battery is discharging" }
    2 { "The system has access to AC so no battery is being discharged. However, the battery is not necessarily charging." }
    3 { "Fully Charged" }
    4 { "Low" }
    5 { "Critical" }
    6 { "Charging" }
    7 { "Charging and High" }
    8 { "Charging and Low" }
    9 { "Charging and Critical " }
    10 { "Unknown State" }
    11 { "Partially Charged" }            

    }
}
}

This powershell function helps you to identify current status of laptop battery. Hope this helps..


{ 0 comments… add one }

Leave a Comment