This project is read-only.


Topics: Archive - General
Apr 27, 2014 at 11:37 AM
Edited Apr 27, 2014 at 12:30 PM

Excuse me for my bad english
On function Test-Battery,if your laptop can have multiple batteries, the test does not work if only one battery is present and on the sector. If you use the code below, it works:
write-host "Testing power connection status..."

$onPower = $false

$batteryStatus = Get-WmiObject -Class BatteryStatus -Namespace root\wmi -ComputerName . -ErrorAction SilentlyContinue
If ($batteryStatus) {
    $batteryStatus|foreach {
        $power = $_.PowerOnLine
        If ($power) {
            write-host "AC Power connection found."
            $onPower = $true

    if ($onPower) 
        {Return $false}

write-host "AC Power connection not found"
Return $true

Apr 29, 2014 at 2:00 PM
Hi Eric,

Nice catch thanks! I'll include this change in the next release.