Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

BatteryHealth

A PowerShell script that checks your laptop's battery health and life using Windows' built-in battery report (powercfg /batteryreport) — the tool Microsoft officially recommends for this.

What it does

  1. Runs powercfg /batteryreport to generate the official HTML battery report.
  2. Parses the report to extract:
    • Design Capacity — the battery's capacity when new
    • Full Charge Capacity — its current maximum capacity
    • Cycle Count (if available)
    • Battery life estimate — "since OS install", at full charge and at design capacity
  3. Calculates battery health % = Full Charge Capacity ÷ Design Capacity.
  4. Prints a color-coded summary to the console and opens the full HTML report in your browser.

Requirements

  • Windows 10/11 with a battery (laptop or tablet)
  • PowerShell (built in — no modules needed)
  • No admin rights required

Usage

powershell -ExecutionPolicy Bypass -File .\BatteryHealth.ps1

Or, from an existing PowerShell session:

.\BatteryHealth.ps1

Example output

===== Battery Health Report =====
Design Capacity:      32,560 mWh
Full Charge Capacity: 26,625 mWh
Battery Health:       81.8%

Estimated battery life (since OS install):
  At full charge:    2:41:38 (h:mm:ss)
  At design capacity: 3:17:40 (h:mm:ss)

Full HTML report saved at: C:\Users\<you>\AppData\Local\Temp\battery-report.html
Opening report in default browser...
  • 🟢 Green: health ≥ 80%
  • 🟡 Yellow: health 50–79%
  • 🔴 Red: health < 50%

How it works under the hood

Windows' battery report HTML sometimes inserts a line break inside table cells (e.g. 32,560 mWh followed by a newline before the closing </td>). The script's regex patterns are written to tolerate that — they match on "any character that isn't a tag" rather than the more common (but newline-blind) . wildcard, so parsing stays reliable across different Windows builds/locales.

Limitations

  • Only reads the primary/first battery if multiple are listed.
  • Cycle count isn't reported by all hardware/firmware — Windows will show - in that case.
  • Battery life estimates are based on your own historical usage, not a fixed benchmark, so they'll vary with how you use the device.

License

MIT — do whatever you like with it.

About

A PowerShell script that checks your laptop's battery health and life using Windows' built-in battery report.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages