答案1
找到的WakeUpType
财产Win32_ComputerSystem
班级
唤醒类型
数据类型:
uint16
访问类型:Read-only
限定符:MappingStrings(“SMBIOS|Type 1|System Information|Wake-up Type
”)导致系统启动的事件。
该值来自唤醒类型成员系统信息结构中的系统管理基本输入输出系统信息。
- Reserved (0) - Other (1) - Unknown (2) - APM Timer (3) - Modem Ring (4) - LAN Remote (5) - Power Switch (6) - PCI PME# (7) - AC Power Restored (8)
下一个脚本需要进行以下调整以满足(您的)特定的操作情况:
$computers
数组(例如从文件中读取);$WakeUpType = Get-WmiObject
(例如添加-Authentication
或-Credential
等参数,参见Get-Help 'Get-WmiObject' -ShowWindow
)。
$WakeUpTypes = DATA {ConvertFrom-StringData -StringData @’
0 = Reserved (0)
1 = Other (1)
2 = Unknown (2)
3 = APM Timer (3)
4 = Modem Ring (4)
5 = LAN Remote (5)
6 = Power Switch (6)
7 = PCI PME# (7)
8 = AC Power Restored (8)
na = ? unreachable ? (N/A)
‘@}
$computers = ".", "$env:COMPUTERNAME", ### I *know* that these are the same
"bububu" ### and this is fake name for debugging
$namespace = "ROOT\CIMV2"
$classname = "Win32_ComputerSystem"
ForEach ( $computer in $computers ) {
Try {
$WakeUpType = Get-WmiObject `
-Class $classname -ComputerName $computer -Namespace $namespace `
-ErrorAction SilentlyContinue
$WakeUpName = $WakeUpTypes.Item("$($WakeUpType.WakeUpType)")
} Catch {
$WakeUpName = $WakeUpTypes.Item("na")
}
If ( $WakeUpName -eq $null ) { $WakeUpName = "Undefined as yet ($WakeUpType)" }
"{0,-20} {1}" -f $computer, $WakeUpName
}
答案2
在 PowerShell 中运行
Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -Property e,WakeUpType