Как вывести Powercfg / availablesleepstates в объекты с помощью powershell - PullRequest
1 голос
/ 03 марта 2020

Вывод командной строки:

C:\powercfg -availablesleepstates
The following sleep states are available on this system:
    Standby (S3)
    Hibernate
    Hybrid Sleep
    Fast Startup

The following sleep states are not available on this system:
    Standby (S1)
        The system firmware does not support this standby state.

    Standby (S2)
        The system firmware does not support this standby state.

    Standby (S0 Low Power Idle)
        The system firmware does not support this standby state.

Сценарий powershell:

$info = (powercfg /a | Select-String -Pattern "sleep states are available" -context 4) | select -Last 4
$items = $info -split ","
$ourObject = New-Object -TypeName psobject

$ourObject | Add-Member -MemberType NoteProperty -Name PCFG0bj -Value $items -Force
$ourObject | fl

Output:
PCFG0bj : {> The following sleep states are available on this system:
                Standby (S3)
                Hibernate
                Hybrid Sleep
                Fast Startup}
...