I’ve tested this on two HP laptops and a Dell laptop. The Dell is on 1511, one HP is on 1607 and the other on Insider Build 14931.  So far, it’s been 100% correct.

function Test-OnBatteryPower {
  ($(Get-WmiObject -Class batterystatus -Namespace root\wmi | Select -ExpandProperty Discharging) -eq $True)
}
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s