Skip to content
Menu

Laptop Battery Worn Out - Capacity and Cycle Count

Compares each battery's full-charge capacity with its design capacity as a health percent, shows the cycle count, and alerts when health drops below MinHealthPercent.

Laptop battery worn out - capacity and cycle count is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Laptop battery worn out - capacity and cycle count. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11, Windows Server 2016+; runs as SYSTEM
NeedsPowerShell 5.1; administrator rights
Read-onlyReads, changes nothing

What It Does

The script is read-only. For each battery it compares the full-charge capacity, what the battery holds today, with the design capacity, what it held new, as a health percent rounded to a whole number, and shows the charge cycle count. It alerts when any battery's health is below MinHealthPercent.

Capacity comes from the battery's WMI classes in root\wmi: BatteryStaticData, BatteryFullChargedCapacity and BatteryCycleCount. When those return nothing, the script writes the Windows battery report with powercfg /batteryreport /xml to a temporary file, reads it, and deletes it. Cycle counts are shown as not reported when the battery does not report one, which many do not.

It is SKIPPED on PCs with no battery, such as desktops, servers and virtual machines, and when a battery is present but reports no capacity. A UPS attached over USB shows up as a battery on a desktop.

Before You Run It

  • Set MinHealthPercent to the point where the client wants the battery replaced. The default is 60.
  • Do not treat a missing cycle count as a fault. Many batteries do not report one.
  • Schedule it monthly in your RMM and alert on exit 1 to plan replacements.
  • Run it as an administrator or SYSTEM.

Type and Risk

  • Type: Monitor. It checks one condition. It exits 1 when it finds the problem, so your RMM can alert on it, 0 when all is well, and 2 when it could not run.
  • Risk: Low. It reads and changes nothing.
  • Restart: It never restarts the machine.
  • Typical run: Under 15 seconds.
  • Example answer: "Battery 1 at 54% of design capacity, 612 cycles; limit 60%"
  • Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • MinHealthPercent: Alert when a battery's full-charge capacity is below this percent of its design capacity. Whole number, 1 to 100. Default 60.

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

test-battery-health.ps1 · 844 lines · 42.5 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.