Win32_Battery

Represents a battery. Some notebooks use more than one battery and return more than one instance. Systems without a battery yield no instances.

Each instance of Win32_Battery represents a battery. PCs without batteries return zero instances. Notebooks return one instance per installed battery.

Examples

You can determine the number of batteries installed in a computer:

# get number of batteries:
$count = @(Get-CimInstance -ClassName Win32_Battery).Count
"Installed batteries: $count"

# test for battery:
$hasBattery = @(Get-CimInstance -ClassName Win32_Battery).Count -gt 0
"Has battery: $hasBattery"

Getting Battery Charge

EstimatedChargeRemaining returns the current charge in percent:

# get battery charge:
$charge = Get-CimInstance -ClassName Win32_Battery | Select-Object -ExpandProperty EstimatedChargeRemaining

"Current Charge: $charge %."

This would return the charge per battery. If you use a notebook with more than one battery installed, this example would not work since $charge now would be an array. A better approach is to calculate the average for all battery charges which works for one or more batteries:

# get battery charge for one or more batteries:
$charge = Get-CimInstance -ClassName Win32_Battery | Measure-Object -Property EstimatedChargeRemaining -Average | Select-Object -ExpandProperty Average

"Current Charge: $charge %."

EstimatedRunTime returns the number of minutes your computer can last on the current battery charge. This property returns valid values only when the computer is running on battery power. When running on AC power, the property always returns 71582788.

Again, to handle cases when more than one battery is used, you need to average the value

# get battery runtime:
$runtime = Get-CimInstance -ClassName Win32_Battery | Measure-Object -Property EstimatedRunTime -Average | Select-Object -ExpandProperty Average

if ($runtime -eq 71582788)
{
  # this specific value indicates AC power:
  'AC Power'
}
else
{
  # return runtime in hours:
  'Estimated Runtime: {0:n1} hours.' -f ($runtime/60)
}

Battery Status

The property BatteryStatus returns a numeric code. Some drivers report values of 1 or 2 only, differentiating between AC and battery power. Other drivers report detailed information about the charge status:

$BatteryStatus = @{
  Name = 'BatteryStatusText'
  Expression = {
    $value = $_.BatteryStatus
    
    switch([int]$value)
    {
        1          {'Battery Power'}
        2          {'AC Power'}
        3          {'Fully Charged'}
        4          {'Low'}
        5          {'Critical'}
        6          {'Charging'}
        7          {'Charging and High'}
        8          {'Charging and Low'}
        9          {'Charging and Critical'}
        10         {'Undefined'}
        11         {'Partially Charged'}
        default    {"$value"}
    }
  }  
}

Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, BatteryStatus, $BatteryStatus

Remote Access

To access remote system(s), use the parameter -ComputerName:

Get-CimInstance -ClassName Win32_Battery -ComputerName laptop12, laptop23

Learn more about accessing remote computers.

Methods

Win32_Battery has no methods. Inherited methods (Reset and SetPowerState) are not implemented.

Properties

Win32_Battery returns 32 properties:

'Availability','BatteryStatus','Caption','Chemistry','ConfigManagerErrorCode',
'ConfigManagerUserConfig','CreationClassName','Description','DesignCapacity','DesignVoltage','DeviceID',
'ErrorCleared','ErrorDescription','EstimatedChargeRemaining','EstimatedRunTime',
'ExpectedBatteryLife','ExpectedLife','FullChargeCapacity','InstallDate','LastErrorCode','MaxRechargeTime',
'Name','PNPDeviceID','PowerManagementCapabilities','PowerManagementSupported',
'SmartBatteryVersion','Status','StatusInfo','SystemCreationClassName','SystemName','TimeOnBattery',
'TimeToFullCharge'

Unless explicitly marked as WRITEABLE, all properties are read-only.

Availability

UINT32

Availability and status of the device.

Availability returns a numeric value. To translate it into a meaningful text, use any of the following approaches:

Use Update-Type

Update-Type tells PowerShell how to interpret the property. This command needs to be executed only once per PowerShell session:

Update-TypeData -MemberName Availability -TypeName "Microsoft.Management.Infrastructure.CimInstance#root/cimv2/win32_battery" -MemberType ScriptProperty  -Value {
  Enum EnumAvailability
  {
    Other                       = 1
    Unknown                     = 2
    RunningFull_Power           = 3
    Warning                     = 4
    In_Test                     = 5
    Not_Applicable              = 6
    Power_Off                   = 7
    Off_Line                    = 8
    Off_Duty                    = 9
    Degraded                    = 10
    Not_Installed               = 11
    Install_Error               = 12
    Power_Save_Unknown          = 13
    Power_Save_Low_Power_Mode   = 14
    Power_Save_Standby          = 15
    Power_Cycle                 = 16
    Power_Save_Warning          = 17
    Paused                      = 18
    Not_Ready                   = 19
    Not_Configured              = 20
    Quiesced                    = 21
  }

  [EnumAvailability]($this.PSBase.CimInstanceProperties['Availability'].Value)
} -Force

Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, Availability
Use Select-Object

Select-Object supports calculated properties. When you submit a hashtable, PowerShell dynamically calculates the result:

$Availability = @{
  Name = 'AvailabilityText'
  Expression = {
    $value = $_.Availability
    
    switch([int]$value)
      {
        1          {'Other'}
        2          {'Unknown'}
        3          {'Running/Full Power'}
        4          {'Warning'}
        5          {'In Test'}
        6          {'Not Applicable'}
        7          {'Power Off'}
        8          {'Off Line'}
        9          {'Off Duty'}
        10         {'Degraded'}
        11         {'Not Installed'}
        12         {'Install Error'}
        13         {'Power Save - Unknown'}
        14         {'Power Save - Low Power Mode'}
        15         {'Power Save - Standby'}
        16         {'Power Cycle'}
        17         {'Power Save - Warning'}
        18         {'Paused'}
        19         {'Not Ready'}
        20         {'Not Configured'}
        21         {'Quiesced'}
        default    {"$value"}
      }
      
  }  
}

Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, Availability, $Availability
Use a PowerShell Hashtable

You can use a PowerShell hashtable to decode numeric values. Use a hashtable like this one:

$Availability_map = @{
      1 = 'Other'
      2 = 'Unknown'
      3 = 'Running/Full Power'
      4 = 'Warning'
      5 = 'In Test'
      6 = 'Not Applicable'
      7 = 'Power Off'
      8 = 'Off Line'
      9 = 'Off Duty'
     10 = 'Degraded'
     11 = 'Not Installed'
     12 = 'Install Error'
     13 = 'Power Save - Unknown'
     14 = 'Power Save - Low Power Mode'
     15 = 'Power Save - Standby'
     16 = 'Power Cycle'
     17 = 'Power Save - Warning'
     18 = 'Paused'
     19 = 'Not Ready'
     20 = 'Not Configured'
     21 = 'Quiesced'
}
Use Enum structure

You can cast the raw property values to a new enum type to translate raw numeric values into friendly text. Use an enum like this one:

Enum EnumAvailability
{
  Other                       = 1
  Unknown                     = 2
  RunningFull_Power           = 3
  Warning                     = 4
  In_Test                     = 5
  Not_Applicable              = 6
  Power_Off                   = 7
  Off_Line                    = 8
  Off_Duty                    = 9
  Degraded                    = 10
  Not_Installed               = 11
  Install_Error               = 12
  Power_Save_Unknown          = 13
  Power_Save_Low_Power_Mode   = 14
  Power_Save_Standby          = 15
  Power_Cycle                 = 16
  Power_Save_Warning          = 17
  Paused                      = 18
  Not_Ready                   = 19
  Not_Configured              = 20
  Quiesced                    = 21
}

BatteryStatus

UINT16

Status of the battery. The status may change depending on whether the computer is connected to AC power or running on battery. Some systems report just whether they are using AC or battery power while others report distinct battery loading states.

BatteryStatus returns a numeric value. To translate it into a meaningful text, use any of the following approaches:

Use Update-Type

Update-Type tells PowerShell how to interpret the property. This command needs to be executed only once per PowerShell session:

Update-TypeData -MemberName BatteryStatus -TypeName "Microsoft.Management.Infrastructure.CimInstance#root/cimv2/win32_battery" -MemberType ScriptProperty  -Value {
  Enum EnumBatteryStatus
  {
    Battery_Power           = 1
    AC_Power                = 2
    Fully_Charged           = 3
    Low                     = 4
    Critical                = 5
    Charging                = 6
    Charging_and_High       = 7
    Charging_and_Low        = 8
    Charging_and_Critical   = 9
    Undefined               = 10
    Partially_Charged       = 11
  }

  [EnumBatteryStatus]($this.PSBase.CimInstanceProperties['BatteryStatus'].Value)
} -Force

Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, BatteryStatus
Use Select-Object

Select-Object supports calculated properties. When you submit a hashtable, PowerShell dynamically calculates the result:

$BatteryStatus = @{
  Name = 'BatteryStatusText'
  Expression = {
    $value = $_.BatteryStatus
    
    switch([int]$value)
      {
        1          {'Battery Power'}
        2          {'AC Power'}
        3          {'Fully Charged'}
        4          {'Low'}
        5          {'Critical'}
        6          {'Charging'}
        7          {'Charging and High'}
        8          {'Charging and Low'}
        9          {'Charging and Critical'}
        10         {'Undefined'}
        11         {'Partially Charged'}
        default    {"$value"}
      }
      
  }  
}

Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, BatteryStatus, $BatteryStatus
Use a PowerShell Hashtable

You can use a PowerShell hashtable to decode numeric values. Use a hashtable like this one:

$BatteryStatus_map = @{
      1 = 'Battery Power'
      2 = 'AC Power'
      3 = 'Fully Charged'
      4 = 'Low'
      5 = 'Critical'
      6 = 'Charging'
      7 = 'Charging and High'
      8 = 'Charging and Low'
      9 = 'Charging and Critical'
     10 = 'Undefined'
     11 = 'Partially Charged'
}
Use Enum structure

You can cast the raw property values to a new enum type to translate raw numeric values into friendly text. Use an enum like this one:

Enum EnumBatteryStatus
{
  Battery_Power           = 1
  AC_Power                = 2
  Fully_Charged           = 3
  Low                     = 4
  Critical                = 5
  Charging                = 6
  Charging_and_High       = 7
  Charging_and_Low        = 8
  Charging_and_Critical   = 9
  Undefined               = 10
  Partially_Charged       = 11
}

Caption

STRING MAX 64 CHAR

Short description as a one-line string.

# returning class instances:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, Caption

# reading property value:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, Caption | Foreach-Object {

  $DeviceID = $_.DeviceID
  $value = $_.Caption
  "${DeviceID}: Caption = $value"
}

Chemistry

UINT16

Enumeration that describes the battery’s chemistry. Whether the battery chemistry is exposed depends on the driver. Some batteries report Unknown.

Chemistry returns a numeric value. To translate it into a meaningful text, use any of the following approaches:

Use Update-Type

Update-Type tells PowerShell how to interpret the property. This command needs to be executed only once per PowerShell session:

Update-TypeData -MemberName Chemistry -TypeName "Microsoft.Management.Infrastructure.CimInstance#root/cimv2/win32_battery" -MemberType ScriptProperty  -Value {
  Enum EnumChemistry
  {
    Other                  = 1
    Unknown                = 2
    Lead_Acid              = 3
    Nickel_Cadmium         = 4
    Nickel_Metal_Hydride   = 5
    Lithium_ion            = 6
    Zinc_air               = 7
    Lithium_Polymer        = 8
  }

  [EnumChemistry]($this.PSBase.CimInstanceProperties['Chemistry'].Value)
} -Force

Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, Chemistry
Use Select-Object

Select-Object supports calculated properties. When you submit a hashtable, PowerShell dynamically calculates the result:

$Chemistry = @{
  Name = 'ChemistryText'
  Expression = {
    $value = $_.Chemistry
    
    switch([int]$value)
      {
        1          {'Other'}
        2          {'Unknown'}
        3          {'Lead Acid'}
        4          {'Nickel Cadmium'}
        5          {'Nickel Metal Hydride'}
        6          {'Lithium-ion'}
        7          {'Zinc air'}
        8          {'Lithium Polymer'}
        default    {"$value"}
      }
      
  }  
}

Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, Chemistry, $Chemistry
Use a PowerShell Hashtable

You can use a PowerShell hashtable to decode numeric values. Use a hashtable like this one:

$Chemistry_map = @{
      1 = 'Other'
      2 = 'Unknown'
      3 = 'Lead Acid'
      4 = 'Nickel Cadmium'
      5 = 'Nickel Metal Hydride'
      6 = 'Lithium-ion'
      7 = 'Zinc air'
      8 = 'Lithium Polymer'
}
Use Enum structure

You can cast the raw property values to a new enum type to translate raw numeric values into friendly text. Use an enum like this one:

Enum EnumChemistry
{
  Other                  = 1
  Unknown                = 2
  Lead_Acid              = 3
  Nickel_Cadmium         = 4
  Nickel_Metal_Hydride   = 5
  Lithium_ion            = 6
  Zinc_air               = 7
  Lithium_Polymer        = 8
}

ConfigManagerErrorCode

UINT32

Windows Configuration Manager error code.

This property is inherited and always empty.

ConfigManagerUserConfig

BOOL

If $true, the device is using a user-defined configuration.

This property is inherited and always empty.

CreationClassName

STRING

Name of the first concrete class that appears in the inheritance chain used in the creation of an instance. When used with the other key properties of the class, the property allows all instances of this class and its subclasses to be identified uniquely.

Description

STRING

Description of the object.

# returning class instances:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, Description

# reading property value:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, Description | Foreach-Object {

  $DeviceID = $_.DeviceID
  $value = $_.Description
  "${DeviceID}: Description = $value"
}

DesignCapacity

UINT32 “MILLIWATT-HOURS”

Design capacity of the battery in milliwatt-hours. If the property is not supported, this is 0 or empty.

This property is null if the driver does not provide this information.

DesignVoltage

UINT64 “MILLIVOLTS”

Design voltage of the battery in millivolts. If the attribute is not supported, this is 0 or empty.

# returning class instances:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, DesignVoltage

# reading property value:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, DesignVoltage | Foreach-Object {

  $DeviceID = $_.DeviceID
  $value = $_.DesignVoltage
  "${DeviceID}: DesignVoltage = $value millivolts"
  'DesignVoltage = {0:n1} Volts' -f ($value/1000)
}

You can update the PowerShell type database to automatically convert the raw property value. This example illustrates overwriting ToString() method to provide formatted output while leaving the original property value untouched:

# outputting raw value:
Get-CimInstance -ClassName Win32_Battery | Select-Object -ExpandProperty DesignVoltage

# updating type database (needs to be done only once per PowerShell session)
# this command instructs PowerShell to overwrite the method ToString() and automatically divide the raw value and transform it in a different unit:
Update-TypeData -MemberName DesignVoltage -TypeName 'Microsoft.Management.Infrastructure.CimInstance#root/cimv2/win32_battery' -MemberType ScriptProperty -Value { ($this.PSBase.CimInstanceProperties['DesignVoltage'].Value) | Add-Member -MemberType ScriptMethod -Name ToString -Force -Value { "{0:n3} Volts" -f ($this/1000) } -PassThru } -Force

# compare the results of the identical command.
# raw values are now automatically transformed into a more meaningful unit:
Get-CimInstance -ClassName Win32_Battery | Select-Object -ExpandProperty DesignVoltage

DeviceID

KEY PROPERTY STRING

Identifies the battery. Example: “Internal Battery”

# returning class instances:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID

# reading property value:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, DeviceID | Foreach-Object {

  $DeviceID = $_.DeviceID
  $value = $_.DeviceID
  "${DeviceID}: DeviceID = $value"
}

ErrorCleared

BOOL

If $true, the error reported in the LastErrorCode property is now cleared.

Typically, this property is empty.

# returning class instances:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, ErrorCleared

# filtering all instances with ErrorCleared set to $true:
Get-CimInstance -ClassName Win32_Battery | Where-Object ErrorCleared -eq $true | Select-Object -Property DeviceID, ErrorCleared

ErrorDescription

STRING

Free-form string that supplies more information about the error recorded in LastErrorCode property, and information about any corrective actions that may be taken.

Typically, this property is empty.

# returning class instances:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, ErrorDescription

# reading property value:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, ErrorDescription | Foreach-Object {

  $DeviceID = $_.DeviceID
  $value = $_.ErrorDescription
  "${DeviceID}: ErrorDescription = $value"
}

EstimatedChargeRemaining

UINT16 “PERCENT”

Estimate of the percentage of full charge remaining.

# returning class instances:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, EstimatedChargeRemaining

# reading property value:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, EstimatedChargeRemaining | Foreach-Object {

  $DeviceID = $_.DeviceID
  $value = $_.EstimatedChargeRemaining
  "${DeviceID}: EstimatedChargeRemaining = $value percent"
'EstimatedChargeRemaining = {0:p1} Volts' -f ($value/100)
}

You can update the PowerShell type database to automatically convert the raw property value. This example illustrates overwriting ToString() method to provide formatted output while leaving the original property value untouched:

# outputting raw value:
Get-CimInstance -ClassName Win32_Battery | Select-Object -ExpandProperty EstimatedChargeRemaining

# updating type database (needs to be done only once per PowerShell session)
# this command instructs PowerShell to overwrite the method ToString() and automatically divide the raw value and transform it in a different unit:
Update-TypeData -MemberName EstimatedChargeRemaining -TypeName 'Microsoft.Management.Infrastructure.CimInstance#root/cimv2/win32_battery' -MemberType ScriptProperty -Value { ($this.PSBase.CimInstanceProperties['EstimatedChargeRemaining'].Value) | Add-Member -MemberType ScriptMethod -Name ToString -Force -Value { "{0:p1} " -f ($this/100) } -PassThru } -Force

# compare the results of the identical command.
# raw values are now automatically transformed into a more meaningful unit:
Get-CimInstance -ClassName Win32_Battery | Select-Object -ExpandProperty EstimatedChargeRemaining

EstimatedRunTime

UINT32 “MINUTES”

Estimate in minutes of the time to battery charge depletion under the present load conditions if the utility power is off, or lost and remains off, or a laptop is disconnected from a power source.

This information is valid only when the computer is disconnected from AC power and running on battery power.

# returning class instances:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, EstimatedRunTime

# reading property value:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, EstimatedRunTime | Foreach-Object {

  $DeviceID = $_.DeviceID
  $value = $_.EstimatedRunTime
  "${DeviceID}: EstimatedRunTime = $value minutes"
  if ($value -eq 71582788)
  {
    'AC Power'
  }
  else
  {
    'EstimatedRunTime = {0:n1} hours' -f ($value/60)
  }
}

You can update the PowerShell type database to automatically convert the raw property value. This example illustrates overwriting ToString() method to provide formatted output while leaving the original property value untouched:

# outputting raw value:
Get-CimInstance -ClassName Win32_Battery | Select-Object -ExpandProperty EstimatedRunTime

# updating type database (needs to be done only once per PowerShell session)
# this command instructs PowerShell to overwrite the method ToString() and automatically divide the raw value and transform it in a different unit:
Update-TypeData -MemberName EstimatedRunTime -TypeName 'Microsoft.Management.Infrastructure.CimInstance#root/cimv2/win32_battery' -MemberType ScriptProperty -Value { ($this.PSBase.CimInstanceProperties['EstimatedRunTime'].Value) | Add-Member -MemberType ScriptMethod -Name ToString -Force -Value { if ($this -eq 71582788) { 'AC Power' } else { "{0:n1} hours" -f ($this/60)} } -PassThru } -Force

# compare the results of the identical command.
# raw values are now automatically transformed into a more meaningful unit:
Get-CimInstance -ClassName Win32_Battery | Select-Object -ExpandProperty EstimatedRunTime

ExpectedBatteryLife

UINT32 “MINUTES”

Amount of time it takes to completely drain the battery after it is fully charged.

This property is no longer used and is considered obsolete.

ExpectedLife

UINT32 “MINUTES”

Battery’s expected lifetime in minutes, assuming that the battery is fully charged. The property represents the total expected life of the battery, not its current remaining life, which is indicated by the EstimatedRunTime property.

This property is null if the driver does not provide this information.

FullChargeCapacity

UINT32 “MILLIWATT-HOURS”

Full charge capacity of the battery in milliwatt-hours. Comparison of the value to the DesignCapacity property determines when the battery requires replacement. A battery’s end of life is typically when the FullChargeCapacity property falls below 80% of the DesignCapacity property. If the property is not supported, enter 0 (zero).

This property is null if the driver does not provide this information.

InstallDate

DATETIME

Date and time the object was installed. This property does not need a value to indicate that the object is installed.

This property is inherited and always empty.

LastErrorCode

UINT32

Last error code reported by the logical device.

# returning class instances:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, LastErrorCode

# reading property value:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, LastErrorCode | Foreach-Object {

  $DeviceID = $_.DeviceID
  $value = $_.LastErrorCode
  "${DeviceID}: LastErrorCode = $value"
}

MaxRechargeTime

UINT32 “MINUTES”

Maximum time, in minutes, to fully charge the battery. The property represents the time to recharge a fully depleted battery, not the current remaining charge time, which is indicated in the TimeToFullCharge property.

This property is null if the driver does not provide this information.

Name

STRING

Defines the label by which the object is known. When subclassed, the property can be overridden to be a key property.

# returning class instances:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, Name

# reading property value:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, Name | Foreach-Object {

  $DeviceID = $_.DeviceID
  $value = $_.Name
  "${DeviceID}: Name = $value"
}

PNPDeviceID

STRING

Windows Plug and Play device identifier of the logical device. This property may be empty if the battery is not a plug&play component and a fixed component of the computer.

Example: “*PNP030b”

# returning class instances:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, PNPDeviceID

# reading property value:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, PNPDeviceID | Foreach-Object {

  $DeviceID = $_.DeviceID
  $value = $_.PNPDeviceID
  "${DeviceID}: PNPDeviceID = $value"
}

PowerManagementCapabilities

UINT16 ARRAY

Array of the specific power-related capabilities of a logical device.

This property is inherited and typically empty.

PowerManagementSupported

BOOL

If $true, device can be power-managed, for example, a device can be put into suspend mode, and so on. This property does not indicate that power management features are enabled currently, but it does indicate that the logical device is capable of power management.

This property is inherited and typically empty.

SmartBatteryVersion

STRING MAX 64 CHAR

Data Specification version number supported by the battery. If the battery does not support this function, the value is empty.

# returning class instances:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, SmartBatteryVersion

# reading property value:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, SmartBatteryVersion | Foreach-Object {

  $DeviceID = $_.DeviceID
  $value = $_.SmartBatteryVersion
  "${DeviceID}: SmartBatteryVersion = $value"
}

Status

STRING MAX 10 CHAR

Current status of an object. Various operational and nonoperational statuses can be defined.

Available values:

'Degraded','Error','Lost Comm','No Contact','NonRecover','OK','Pred Fail','Service','Starting','Stopping','Stressed','Unknown'
# returning class instances:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, Status

# reading property value:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, Status | Foreach-Object {

  $DeviceID = $_.DeviceID
  $value = $_.Status
  "${DeviceID}: Status = $value"
}

StatusInfo

UINT16

State of the logical device. If this property does not apply to the logical device, the value 5 (Not Applicable) should be used.

This property is inherited and always empty.

SystemCreationClassName

STRING

Value of the scoping computer’s CreationClassName property.

SystemName

STRING

Name of the scoping system.

# returning class instances:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, SystemName

# reading property value:
Get-CimInstance -ClassName Win32_Battery | Select-Object -Property DeviceID, SystemName | Foreach-Object {

  $DeviceID = $_.DeviceID
  $value = $_.SystemName
  "${DeviceID}: SystemName = $value"
}

TimeOnBattery

UINT32 “SECONDS”

Elapsed time in seconds since the computer system’s UPS last switched to battery power, or the time since the system or UPS was last restarted, whichever is less. If the battery is “on line”, 0 (zero) is returned.

This property is null if the driver does not provide this information.

TimeToFullCharge

UINT32 “MINUTES”

Remaining time to charge the battery fully in minutes at the current charging rate and usage.

This property is null if the driver does not provide this information.

CDXML Definition

You can turn this WMI class and its methods into PowerShell cmdlets by importing below CDXML file (Cmdlet Definition XML) as a module.

Create Win32_Battery.cdxml
$folder = "c:\wmi\Win32_Battery"
$cdxmlPath = Join-Path -Path $folder -ChildPath "Win32_Battery.cdxml"

# create folder if not present:
$exists = Test-Path -Path $folder
if (!$exists) { $null = New-Item -Path $folder -ItemType Directory }

# write file
$content = @'
<?xml version="1.0" encoding="utf-8"?>


<!--
This file is licensed under 'Attribution 4.0 International' license (https://creativecommons.org/licenses/by/4.0/).

You can free of charge use this code in commercial and non-commercial code, and you can freely modify and adjust the code 
as long as you give appropriate credit to the original author Dr. Tobias Weltner.

This material was published and is maintained here: 

https://powershell.one/wmi/root/cimv2/win32_battery#cdxml-definition
-->


<PowerShellMetadata xmlns="http://schemas.microsoft.com/cmdlets-over-objects/2009/11">
  <!--referencing the WMI class this cdxml uses-->
  <Class ClassName="Root/CIMV2\Win32_Battery" ClassVersion="2.0">
    <Version>1.0</Version>
    <!--default noun used by Get-cmdlets and when no other noun is specified. By convention, we use the prefix "WMI" and the base name of the WMI class involved. This way, you can easily identify the underlying WMI class.-->
    <DefaultNoun>WmiBattery</DefaultNoun>
    <!--define the cmdlets that work with class instances.-->
    <InstanceCmdlets>
      <!--query parameters to select instances. This is typically empty for classes that provide only one instance-->
      <GetCmdletParameters />
      <GetCmdlet>
        <CmdletMetadata Verb="Get" />
        <GetCmdletParameters>
          <QueryableProperties>
            <Property PropertyName="Availability">
              <Type PSType="Win32_Battery.Availability" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="BatteryStatus">
              <Type PSType="Win32_Battery.BatteryStatus" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="Chemistry">
              <Type PSType="Win32_Battery.Chemistry" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="ConfigManagerErrorCode">
              <Type PSType="Win32_Battery.ConfigManagerErrorCode" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="ConfigManagerUserConfig">
              <Type PSType="switch" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="CreationClassName">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="Description">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="DesignCapacity">
              <Type PSType="system.uint32" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="DesignVoltage">
              <Type PSType="system.uint64" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="DeviceID">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="ErrorCleared">
              <Type PSType="switch" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="ErrorDescription">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="EstimatedChargeRemaining">
              <Type PSType="system.uint16" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="EstimatedRunTime">
              <Type PSType="system.uint32" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="ExpectedBatteryLife">
              <Type PSType="system.uint32" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="ExpectedLife">
              <Type PSType="system.uint32" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="FullChargeCapacity">
              <Type PSType="system.uint32" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="InstallDate">
              <Type PSType="system.datetime" />
              <MinValueQuery>
                <CmdletParameterMetadata PSName="BeforeInstallDate" />
              </MinValueQuery>
              <MaxValueQuery>
                <CmdletParameterMetadata PSName="AfterInstallDate" />
              </MaxValueQuery>
            </Property>
            <Property PropertyName="LastErrorCode">
              <Type PSType="system.uint32" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="MaxRechargeTime">
              <Type PSType="system.uint32" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="Name">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="PNPDeviceID">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="PowerManagementCapabilities">
              <Type PSType="Win32_Battery.PowerManagementCapabilities" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="PowerManagementSupported">
              <Type PSType="switch" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="SmartBatteryVersion">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="Status">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="StatusInfo">
              <Type PSType="Win32_Battery.StatusInfo" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="TimeOnBattery">
              <Type PSType="system.uint32" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="TimeToFullCharge">
              <Type PSType="system.uint32" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
          </QueryableProperties>
        </GetCmdletParameters>
      </GetCmdlet>
      <!--defining additional cmdlets that modifies instance properties-->
    </InstanceCmdlets>
  </Class>
  <!--defining enumerations-->
  <Enums>
    <Enum EnumName="Win32_Battery.Availability" UnderlyingType="system.uint32">
      <Value Name="Other" Value="1" />
      <Value Name="Unknown" Value="2" />
      <Value Name="RunningFullPower" Value="3" />
      <Value Name="Warning" Value="4" />
      <Value Name="InTest" Value="5" />
      <Value Name="NotApplicable" Value="6" />
      <Value Name="PowerOff" Value="7" />
      <Value Name="OffLine" Value="8" />
      <Value Name="OffDuty" Value="9" />
      <Value Name="Degraded" Value="10" />
      <Value Name="NotInstalled" Value="11" />
      <Value Name="InstallError" Value="12" />
      <Value Name="PowerSaveUnknown" Value="13" />
      <Value Name="PowerSaveLowPowerMode" Value="14" />
      <Value Name="PowerSaveStandby" Value="15" />
      <Value Name="PowerCycle" Value="16" />
      <Value Name="PowerSaveWarning" Value="17" />
      <Value Name="Paused" Value="18" />
      <Value Name="NotReady" Value="19" />
      <Value Name="NotConfigured" Value="20" />
      <Value Name="Quiesced" Value="21" />
    </Enum>
    <Enum EnumName="Win32_Battery.BatteryStatus" UnderlyingType="system.uint16">
      <Value Name="BatteryPower" Value="1" />
      <Value Name="ACPower" Value="2" />
      <Value Name="FullyCharged" Value="3" />
      <Value Name="Low" Value="4" />
      <Value Name="Critical" Value="5" />
      <Value Name="Charging" Value="6" />
      <Value Name="ChargingandHigh" Value="7" />
      <Value Name="ChargingandLow" Value="8" />
      <Value Name="ChargingandCritical" Value="9" />
      <Value Name="Undefined" Value="10" />
      <Value Name="PartiallyCharged" Value="11" />
    </Enum>
    <Enum EnumName="Win32_Battery.Chemistry" UnderlyingType="system.uint16">
      <Value Name="Other" Value="1" />
      <Value Name="Unknown" Value="2" />
      <Value Name="LeadAcid" Value="3" />
      <Value Name="NickelCadmium" Value="4" />
      <Value Name="NickelMetalHydride" Value="5" />
      <Value Name="Lithiumion" Value="6" />
      <Value Name="Zincair" Value="7" />
      <Value Name="LithiumPolymer" Value="8" />
    </Enum>
    <Enum EnumName="Win32_Battery.ConfigManagerErrorCode" UnderlyingType="system.uint32">
      <Value Name="OK" Value="0" />
      <Value Name="CONFIGERROR" Value="1" />
      <Value Name="CANNOTLOADDRIVER" Value="2" />
      <Value Name="LOWMEMORY" Value="3" />
      <Value Name="REGISTRYCORRUPTED" Value="4" />
      <Value Name="MANAGEDRESOURCEMISSING" Value="5" />
      <Value Name="BOOTCONFIGCONFLICT" Value="6" />
      <Value Name="CANNOTFILTER" Value="7" />
      <Value Name="DRIVERLOADERMISSING" Value="8" />
      <Value Name="FIRMWARERESOURCEPROBLEM" Value="9" />
      <Value Name="DEVICECANNOTSTART" Value="10" />
      <Value Name="DEVICEFAILED" Value="11" />
      <Value Name="NOTENOUGHFREERESOURCES" Value="12" />
      <Value Name="CANNOTVERIFYRESOURCES" Value="13" />
      <Value Name="RESTARTREQUIRED" Value="14" />
      <Value Name="REENUMERATIONPROBLEM" Value="15" />
      <Value Name="CANNOTIDENTIFYRESOURCE" Value="16" />
      <Value Name="UNKNOWNRESOURCETYPE" Value="17" />
      <Value Name="REINSTALLDRIVERS" Value="18" />
      <Value Name="VXDLOADERFAILURE" Value="19" />
      <Value Name="REGISTRYCORRUPTION" Value="20" />
      <Value Name="DEVICEREMOVEDDUETOERROR" Value="21" />
      <Value Name="DEVICEDISABLED" Value="22" />
      <Value Name="SYSTEMFAILURE" Value="23" />
      <Value Name="DEVICENOTPRESENT" Value="24" />
      <Value Name="DEVICESETUPINPROGRESS" Value="25" />
      <Value Name="DEVICEBEINGINSTALLED" Value="26" />
      <Value Name="NOVALIDLOGCONFIG" Value="27" />
      <Value Name="DRIVERSMISSING" Value="28" />
      <Value Name="DEVICEDISABLEDMISSINGRESOURCES" Value="29" />
      <Value Name="IRQCONFLICT" Value="30" />
      <Value Name="DRIVERNOTLOADED" Value="31" />
    </Enum>
    <Enum EnumName="Win32_Battery.PowerManagementCapabilities" UnderlyingType="system.uint16">
      <Value Name="Unknown" Value="0" />
      <Value Name="NotSupported" Value="1" />
      <Value Name="Disabled" Value="2" />
      <Value Name="Enabled" Value="3" />
      <Value Name="PowerSavingModesEnteredAutomatically" Value="4" />
      <Value Name="PowerStateSettable" Value="5" />
      <Value Name="PowerCyclingSupported" Value="6" />
      <Value Name="TimedPowerOnSupported" Value="7" />
    </Enum>
    <Enum EnumName="Win32_Battery.StatusInfo" UnderlyingType="system.uint16">
      <Value Name="Other" Value="1" />
      <Value Name="Unknown" Value="2" />
      <Value Name="Enabled" Value="3" />
      <Value Name="Disabled" Value="4" />
      <Value Name="NotApplicable" Value="5" />
    </Enum>
  </Enums>
</PowerShellMetadata>
'@ | Set-Content -LiteralPath $cdxmlPath -Encoding UTF8

# import module
Import-Module -Name $cdxmlPath -Force -Verbose

# list new cmdlets
Get-Command -Module "Win32_Battery"

See here for more information on CDXML and CDXML-based PowerShell modules.

Type Extensions for PowerShell

You can automatically improve properties of class instances by using a types.ps1xml file.

Create Win32_Battery.Types.ps1xml
$folder = "c:\wmi\Win32_Battery"
$typesPath = Join-Path -Path $folder -ChildPath "Win32_Battery.Types.ps1xml"

# create folder if not present:
$exists = Test-Path -Path $folder
if (!$exists) { $null = New-Item -Path $folder -ItemType Directory }

# write file
$content = @'
<?xml version="1.0" encoding="utf-8"?>


<!--
This file is licensed under 'Attribution 4.0 International' license (https://creativecommons.org/licenses/by/4.0/).

You can free of charge use this code in commercial and non-commercial code, and you can freely modify and adjust the code 
as long as you give appropriate credit to the original author Dr. Tobias Weltner.

This material was published and is maintained here: 

https://powershell.one/wmi/root/cimv2/win32_battery#typesps1xml-file
-->


<Types>
  <Type>
    <!--@

            Applicable type. This type is produced by Get-CimInstance. 
            To extend instances produced by Get-WmiObject, change the type name to: 

            System.Management.ManagementObject#root/cimv2\Win32_Battery

        @-->
    <Name>Microsoft.Management.Infrastructure.CimInstance#Root/CIMV2/Win32_Battery</Name>
    <Members>
      <ScriptProperty>
        <Name>Availability</Name>
        <!--casting raw content to a enum. This translates numeric values to friendly text while leaving the original property value untouched:-->
        <GetScriptBlock>[Microsoft.PowerShell.Cmdletization.GeneratedTypes.Win32_Battery.Availability]($this.PSBase.CimInstanceProperties['Availability'].Value)</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>BatteryStatus</Name>
        <!--casting raw content to a enum. This translates numeric values to friendly text while leaving the original property value untouched:-->
        <GetScriptBlock>[Microsoft.PowerShell.Cmdletization.GeneratedTypes.Win32_Battery.BatteryStatus]($this.PSBase.CimInstanceProperties['BatteryStatus'].Value)</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>Chemistry</Name>
        <!--casting raw content to a enum. This translates numeric values to friendly text while leaving the original property value untouched:-->
        <GetScriptBlock>[Microsoft.PowerShell.Cmdletization.GeneratedTypes.Win32_Battery.Chemistry]($this.PSBase.CimInstanceProperties['Chemistry'].Value)</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>ConfigManagerErrorCode</Name>
        <!--casting raw content to a enum. This translates numeric values to friendly text while leaving the original property value untouched:-->
        <GetScriptBlock>[Microsoft.PowerShell.Cmdletization.GeneratedTypes.Win32_Battery.ConfigManagerErrorCode]($this.PSBase.CimInstanceProperties['ConfigManagerErrorCode'].Value)</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>DesignVoltage</Name>
        <!--overwriting ToString() method to provide formatted output while leaving the original property value untouched:-->
        <GetScriptBlock>($this.PSBase.CimInstanceProperties['DesignVoltage'].Value) | Add-Member -MemberType ScriptMethod -Name ToString -Force -Value { "{0:n3} Volts" -f ($this/1000) } -PassThru</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>EstimatedChargeRemaining</Name>
        <!--overwriting ToString() method to provide formatted output while leaving the original property value untouched:-->
        <GetScriptBlock>($this.PSBase.CimInstanceProperties['EstimatedChargeRemaining'].Value) | Add-Member -MemberType ScriptMethod -Name ToString -Force -Value { "{0:p1} " -f ($this/100) } -PassThru</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>EstimatedRunTime</Name>
        <!--overwriting ToString() method to provide formatted output while leaving the original property value untouched:-->
        <GetScriptBlock>($this.PSBase.CimInstanceProperties['EstimatedRunTime'].Value) | Add-Member -MemberType ScriptMethod -Name ToString -Force -Value { if ($this -eq 71582788) { 'AC Power' } else { "{0:n1} hours" -f ($this/60)} } -PassThru</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>PowerManagementCapabilities</Name>
        <!--casting raw content to a enum. This translates numeric values to friendly text while leaving the original property value untouched:-->
        <GetScriptBlock>[Microsoft.PowerShell.Cmdletization.GeneratedTypes.Win32_Battery.PowerManagementCapabilities]($this.PSBase.CimInstanceProperties['PowerManagementCapabilities'].Value)</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>StatusInfo</Name>
        <!--casting raw content to a enum. This translates numeric values to friendly text while leaving the original property value untouched:-->
        <GetScriptBlock>[Microsoft.PowerShell.Cmdletization.GeneratedTypes.Win32_Battery.StatusInfo]($this.PSBase.CimInstanceProperties['StatusInfo'].Value)</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
</Types>
'@ | Set-Content -LiteralPath $typesPath -Encoding UTF8

# import type definition
Update-TypeData -PrependPath $typesPath

Note: Win32_Battery.Types.ps1xml is using enumerations defined in ClassName.cdxml which are available only when you imported the .cdxml file via Import-Module.

Or, you can manually update the PowerShell type database using Update-TypeData.

View Update-TypeData commands for Win32_Battery properties
Update-TypeData -MemberName Availability -TypeName "Microsoft.Management.Infrastructure.CimInstance#root/cimv2/win32_battery" -MemberType ScriptProperty  -Value {
  Enum EnumAvailability
  {
    Other                       = 1
    Unknown                     = 2
    RunningFull_Power           = 3
    Warning                     = 4
    In_Test                     = 5
    Not_Applicable              = 6
    Power_Off                   = 7
    Off_Line                    = 8
    Off_Duty                    = 9
    Degraded                    = 10
    Not_Installed               = 11
    Install_Error               = 12
    Power_Save_Unknown          = 13
    Power_Save_Low_Power_Mode   = 14
    Power_Save_Standby          = 15
    Power_Cycle                 = 16
    Power_Save_Warning          = 17
    Paused                      = 18
    Not_Ready                   = 19
    Not_Configured              = 20
    Quiesced                    = 21
  }

  [EnumAvailability]($this.PSBase.CimInstanceProperties['Availability'].Value)
} -Force

Update-TypeData -MemberName BatteryStatus -TypeName "Microsoft.Management.Infrastructure.CimInstance#root/cimv2/win32_battery" -MemberType ScriptProperty  -Value {
  Enum EnumBatteryStatus
  {
    Battery_Power           = 1
    AC_Power                = 2
    Fully_Charged           = 3
    Low                     = 4
    Critical                = 5
    Charging                = 6
    Charging_and_High       = 7
    Charging_and_Low        = 8
    Charging_and_Critical   = 9
    Undefined               = 10
    Partially_Charged       = 11
  }

  [EnumBatteryStatus]($this.PSBase.CimInstanceProperties['BatteryStatus'].Value)
} -Force

Update-TypeData -MemberName Chemistry -TypeName "Microsoft.Management.Infrastructure.CimInstance#root/cimv2/win32_battery" -MemberType ScriptProperty  -Value {
  Enum EnumChemistry
  {
    Other                  = 1
    Unknown                = 2
    Lead_Acid              = 3
    Nickel_Cadmium         = 4
    Nickel_Metal_Hydride   = 5
    Lithium_ion            = 6
    Zinc_air               = 7
    Lithium_Polymer        = 8
  }

  [EnumChemistry]($this.PSBase.CimInstanceProperties['Chemistry'].Value)
} -Force

Update-TypeData -MemberName DesignVoltage -TypeName 'Microsoft.Management.Infrastructure.CimInstance#root/cimv2/win32_battery' -MemberType ScriptProperty -Value { ($this.PSBase.CimInstanceProperties['DesignVoltage'].Value) | Add-Member -MemberType ScriptMethod -Name ToString -Force -Value { "{0:n3} Volts" -f ($this/1000) } -PassThru } -Force

Update-TypeData -MemberName EstimatedChargeRemaining -TypeName 'Microsoft.Management.Infrastructure.CimInstance#root/cimv2/win32_battery' -MemberType ScriptProperty -Value { ($this.PSBase.CimInstanceProperties['EstimatedChargeRemaining'].Value) | Add-Member -MemberType ScriptMethod -Name ToString -Force -Value { "{0:p1} " -f ($this/100) } -PassThru } -Force

Update-TypeData -MemberName EstimatedRunTime -TypeName 'Microsoft.Management.Infrastructure.CimInstance#root/cimv2/win32_battery' -MemberType ScriptProperty -Value { ($this.PSBase.CimInstanceProperties['EstimatedRunTime'].Value) | Add-Member -MemberType ScriptMethod -Name ToString -Force -Value { if ($this -eq 71582788) { 'AC Power' } else { "{0:n1} hours" -f ($this/60)} } -PassThru } -Force

See Also

Associated Classes:

Win32_ComputerSystem

Requirements

To use Win32_Battery, the following requirements apply:

PowerShell

Get-CimInstance was introduced with PowerShell Version 3.0, which in turn was introduced on clients with Windows 8 and on servers with Windows Server 2012.

If necessary, update Windows PowerShell to Windows PowerShell 5.1, or install PowerShell 7 side-by-side.

Operating System

Win32_Battery was introduced on clients with Windows Vista and on servers with Windows Server 2008.

Namespace

Win32_Battery lives in the namespace root/cimv2. This is the default namespace. There is no need to use the -Namespace parameter in Get-CimInstance.

Implementation

Win32_Battery is implemented in CIMWin32.dll and defined in CIMWin32.mof. Both files are located in the folder C:\Windows\system32\wbem:

explorer $env:windir\system32\wbem
notepad $env:windir\system32\wbem\CIMWin32.mof