Access Power and Battery Status with PowerShell. Unfortunately this only applies to Windows
Tested on Windows 10
Detect power status with PowerShell
BatteryChargeStatus, BatteryFullLifetime, BatteryLifePercent, and BatteryLifeRemaining
Code
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.SystemInformation]::PowerStatus
Plugged In
PowerLineStatus : Online BatteryChargeStatus : High BatteryFullLifetime : -1 BatteryLifePercent : 1 BatteryLifeRemaining : -1
Unplugged
PowerLineStatus : Offline BatteryChargeStatus : High BatteryFullLifetime : -1 BatteryLifePercent : 0.95 BatteryLifeRemaining : -1 PowerLineStatus : Offline BatteryChargeStatus : High BatteryFullLifetime : -1 BatteryLifePercent : 0.82 BatteryLifeRemaining : 9369 PowerLineStatus : Offline BatteryChargeStatus : 0 BatteryFullLifetime : -1 BatteryLifePercent : 0.56 BatteryLifeRemaining : 5282
Related
- AWS Tools for PowerShell
- Configure Windows to be Managed via Ansible
- Check for Pending Reboot on Windows
- Extend Volume in Windows
- Install RSAT on Windows
- Enable Telnet Client on Windows 10
- Changing Windows Network Profile
- Moving AD Computer Object with Powershell
- How to check for Suspicious root CA certificates in Windows
- How to setup WinRM in a WorkGroup Non Domain Environment
- How to Start an Application as Another User from the Command Line in WIndows
- How to turn the Windows Firewall On or Off Via the Command Line.
Links
- https://github.com/powershell/powershell