WMI BatteryStatus from Windows Server 2012 using Powershell -


i'm writing powershell script server management when have power outage. presently script using wmi win32)battery class see if batterystatus 1 (discharging) or 2 (unknown (on a/c)) not sure best method. there several statuses true @ same time. example battery discharging (1) , partially charged (11) or on ac (2) critical (5) or charging (6) or partially charged (11). doesn't make sense me. batterystatus reliable intended purpose? how windows determine status returned? in testing i've not seen other statuses of 1 or 2.

the documentation win32_battery indicates availability might indicator on battery. better way go, maybe combination of batterystatus , availability?

in search answers came across looks the perfect answer, using "poweronline" undocumented batterystatus class in root\wmi namespace. works great laptop following error when trying access our windows 2012 server:

ps c:\windows\system32> gwmi -class batterystatus -namespace root\wmi  gwmi : invalid class "batterystatus" @ line:1 char:1 + gwmi -class batterystatus -namespace root\wmi + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + categoryinfo          : invalidtype: (:) [get-wmiobject], managementexception     + fullyqualifiederrorid : getwmimanagementexception,microsoft.powershell.commands.getwmiobjectcommand 

is class not available on servers?

so using wmi, reliable way know if on ups battery or ac power?

thanks help.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -