PowerShell script – Display Battery Information on Windows 11

The following PowerShell script will display the properties information for any batteries available to the Windows system.

The script makes use of the Windows Management Instrumentation (WMI) to fetch battery information and then presents it in a structured manner.

$batteries = Get-WmiObject -Class Win32_Battery

foreach ($battery in $batteries) { Write-Host "Battery Information:" Write-Host "----------------------------------" Write-Host "DeviceID: $($battery.DeviceID)" Write-Host "Name: $($battery.Name)" Write-Host "Manufacturer: $($battery.Manufacturer)" Write-Host "Status: $($battery.Status)" Write-Host "Battery Type: $($battery.BatteryType)" Write-Host "Caption: $($battery.Caption)" Write-Host "Chemistry: $($battery.Chemistry)" Write-Host "Availability: $($battery.Availability)" Write-Host "Battery Recharge Time: $($battery.BatteryRechargeTime) minutes" Write-Host "Battery Status: $($battery.BatteryStatus)" Write-Host "Estimated Charge Remaining: $($battery.EstimatedChargeRemaining)%" Write-Host "Expected Battery Life: $($battery.ExpectedBatteryLife) minutes" Write-Host "Expected Life: $($battery.ExpectedLife) minutes" Write-Host "Time On Battery: $($battery.TimeOnBattery) seconds" Write-Host "Time to Full Charge: $($battery.TimeToFullCharge) minutes" Write-Host "Design Capacity: $($battery.DesignCapacity) mWh" Write-Host "Full Charge Capacity: $($battery.FullChargeCapacity) mWh" Write-Host "Design Voltage: $($battery.DesignVoltage) mV" Write-Host "Smart Battery Version: $($battery.SmartBatteryVersion)" Write-Host "Configuration Manager Error Code: $($battery.ConfigManagerErrorCode)" Write-Host "Power Management Supported: $($battery.PowerManagementSupported)" Write-Host "Power Management Capabilities: $($battery.PowerManagementCapabilities -join ', ')" Write-Host "" }

Read-Host -Prompt "Press Enter to exit..."

How to Use the Script

  1. Open PowerShell: Open PowerShell with administrative rights for better access to system components.
  2. Run the Script: Copy and paste the script into the PowerShell window and press Enter.
  3. Read the Information: The script will print battery-related properties to the screen.
  4. Exit: Press Enter when prompted to close the PowerShell window or to continue with other tasks.

How the Script Works

  • $batteries = Get-WmiObject -Class Win32_Battery: This line fetches all the battery information and stores it in the $batteries variable.
  • foreach ($battery in $batteries): The loop goes through each object stored in $batteries.
  • Write-Host "Property: $($battery.PropertyName)": Each Write-Host line prints the respective property of the battery. For example, $($battery.DeviceID) prints the device ID of the battery.
  • Read-Host -Prompt "Press Enter to exit...": This line keeps the window open until you press Enter.