usr/etc/Get-PowerStatus.ps1

1
2
3
4
5
6
7
8
9
10
11
12
function Get-PowerStatus {
  [CmdletBinding()]param()

  end {
    Add-Type -AssemblyName System.Windows.Forms
    [Windows.Forms.PowerStatus].GetConstructor(
      [Reflection.BindingFlags]'Instance, NonPublic',
      $null, [Type[]]@(), $null
    ).Invoke($null)
  }
}