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
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.