powershell - 如何使用 powershell 将 Powercfg /availablesleepstates 输出到对象中
问题描述
命令行输出:
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}
解决方案
推荐阅读
- swift - 如何创建像 safari 的搜索栏这样的搜索栏?迅速
- excel - 计数匹配行和列变量的值
- java - 检查嵌套的 Java 对象是否为空
- javascript - Javascript:学生的平均成绩和字母成绩
- bootstrap-4 - 全高嵌套行和列 bootstrap 4
- guava - 在给定 SuccessorsFunction 和一组节点的情况下构建 Graph
- spring-boot - 使用没有存储库的 CRNK
- php - OPcache 不缓存任何内容
- c++ - 使用 boost::equality_comparable 有什么区别
与覆盖布尔运算符 ==? - python - 使用正则表达式拆分每个特殊字符的字符串