7
3
On Windows 10 (among other versions) running on a device having a battery, I can use powercfg /batteryreport
to obtain the "Design Capacity" and "Last Full Charge Capacity" for the battery, which give an idea of the remaining useful service life of the battery and how much its capacity has degraded from use.
C:\Users\superuser\AppData\Local\Temp>powercfg /batteryreport
Battery life report saved to C:\Users\superuser\AppData\Local\Temp\battery-report.html
The HTML report is generated instantaneously and displays, among others, the statistics I'm interested in:
Moreover, I can boot into this laptop's built-in diagnostic environment and it displays similar figures, and the discharge cycle count of the battery.
From where are these values being obtained? I would like to be able to track this battery life data over time for a fleet of laptops, preferably from a Powershell script. It seemed likely that this data should be in WMI, and sure enough, there's a Win32_Battery class having DesignCapacity
and FullChargeCapacity
fields, but on all the systems I have tested, they are undefined:
PS C:\Users\superuser> Get-WmiObject -Class Win32_Battery | Select-Object -Property *Capacity | Format-List
DesignCapacity :
FullChargeCapacity :
There must be some programmatic way to access this information, because powercfg
is doing it. If there is some WMI, .NET, or Powershell way to do this, I'd like to know about it. I could generate the powercfg
report and then parse it, but I really don't want to implement an ugly workaround when there is most likely a "right" way to do it that is just escaping me.
well, the windows is able to retrieve that information from the system firmware (BIOS/UEFI) via the ACPI: http://www.acpi.info/ https://en.wikipedia.org/wiki/Advanced_Configuration_and_Power_Interface
– Frank Thomas – 2015-10-31T03:52:54.603+1 good question. I hate it when stuff isn't in WMI or not wrapped by PowerShell. – David Betz – 2015-10-31T06:21:26.867
This capitalization trend is getting ridiculous. LION CHEMISTRY! – beatcracker – 2015-11-02T17:16:37.600
Ah, the "CHEMISTRY" in the HTML reports (black boxes) say LION, presumably referring to Lithium Ion. It took me a while to comprehend just what @beatcracker's comment was saying. – TOOGAM – 2015-11-03T01:26:08.663
@TOOGAM So, it's just me, then :). Still, I want a RACOON CHEMISTRY in my laptop battery, so it would grab whatever power source it could find. – beatcracker – 2015-11-03T02:38:48.347