≡ Menu

Powershell: Check laptop battery status

In this post, I will show you how to pragmatically query battery status in laptops using powershell. It is important to check batter status before performing some critical tasks like patch updates or service pack updates via some automation(s). If the laptop charging drains down in middle of the upgrade, it can corrupt the operating system.

You can use below one liner to check the percentage of charging left in the battery:

(Get-WmiObject -Class Win32_Battery).estimatedchargeremaining

Similarly, if you want to how many more minutes this charging comes, you can use below code:

(Get-WmiObject -Class Win32_Battery).EstimatedRunTime

Hope this helps and you will have crash free upgrades on laptops.

Comments on this entry are closed.

  • Deloras February 25, 2013, 12:30 pm

    Pretty! This has been an extremely wonderful article.
    Many thanks for providing this information.