Michal Košík
Michal Košík

Reputation: 1

Trying to get FullChargeCapacity from Win32_PortableBattery Class

I'm trying to get full charge capacity of remote notebook battery info in our company, but it returns empty output when I run the code. I did some googling and I know I need to ask the driver of the battery for the info (can be found in registry too I think), but I have weak programming skills and have no idea how to do it. I am also doing DesignCapacity instead of FullChargeCapacity at the end of the code, and this one works. Can anyone help me? Thank you

My code:

$NTB_Battery_ActualCapacity = $(Get-WmiObject win32_portablebattery -Computername $remote_PC).FullChargeCapacity

Upvotes: 0

Views: 203

Answers (1)

js2010
js2010

Reputation: 27576

Here's an attempt with powercfg.

powercfg /batteryreport /xml

Battery life report saved to file path C:\Users\admin\battery-report.xml.


[xml]$xml = get-content battery-report.xml
$xml.BatteryReport.Batteries.Battery


Id                 : Primary
Manufacturer       : Hewlett-Packard
SerialNumber       : 12345 2018/04/13
ManufactureDate    :
Chemistry          : LIon
LongTerm           : 1
RelativeCapacity   : 0
DesignCapacity     : 44357
FullChargeCapacity : 44357
CycleCount         : 0


$xml.BatteryReport.Batteries.Battery.FullChargeCapacity

44357

Upvotes: 0

Related Questions