Category filter

Script to fetch battery status from Windows

It is important to watch the battery level of your work devices to ensure employee productivity. Admins can track battery health and avoid situations where a device turns off due to a low battery. Likewise, you can assess battery life and take action to improve performance. Use Hexnode’s Execute Custom Script action to retrieve the battery status of your Windows devices.

Disclaimer:

The Sample Scripts provided below are adapted from third-party Open-Source sites.

PowerShell script to fetch battery status

Run this script to fetch the estimated battery charge remaining on your device.

The command returns the current battery status with the estimated percentage charge remaining.

PowerShell script to view battery health

You can use this command to generate a battery health report of your device and save it on your device at a location you specify.

The command saves a very detailed battery health report of your device on the C drive. These include:

  • Battery Report: Displays system info like computer’s name, BIOS version, OS build, and the date the report was created.
  • Installed batteries: Battery info such as name, manufacturer, serial number, chemistry and design capacity.
  • Recent usage- detailed report of when the device was running on plugged in AC power or battery over the last three days with start time, source, state and remaining capacity.
  • Battery usage- Displays battery drain over the last three days.
  • Usage history-History and duration of device running on AC or battery.
  • Battery capacity history-Full charge capacity vs battery design capacity of the device.
  • Battery life estimates- Estimated battery life at full charge compared to designed capacity.

The report is saved as an HTML file and can be viewed in your default web browser.

Notes:

  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository