November 28th, 2012

PowerTip: Use PowerShell to Determine if a Laptop Is Running on Battery

Doctor Scripto
Scripter

Summary: Learn how to use Windows PowerShell to determine if a laptop is running on battery.

Hey, Scripting Guy! Question How can I use Windows PowerShell to determine if my laptop is running on battery?

Hey, Scripting Guy! AnswerUse the Win32_Battery WMI class and look for a BatteryStatus of 1—this means the battery is discharging (in use). Here is an example using either the Get-WmiObject or the Get-CimInstance cmdlets.

Get-WmiObject Win32_Battery

Get-CimInstance Win32_Battery

 

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback