$computername = "wswincnhz0029" #将“wswincnhz0029”替换为要查询的计算机名称
Invoke-Command -ComputerName $computername -ScriptBlock {
if ((Get-CimInstance -ClassName CIM_ComputerSystem).PCSystemType -ne 0) {
Write-Host "The system is not a desktop or server, so the power state cannot be determined."
}
else {
switch ((Get-CimInstance -ClassName CIM_LogicalElement -Namespace root\cimv2\power -Filter "instancename='\\\\\\\.\\root\\cimv2\\power\\Win32_PowerState'").SystemSuspendState) {
'Standby' {Write-Host "The system is in Standby (Sleep) mode."}
'Hibernate' {Write-Host "The system is in Hibernate mode."}
default {Write-Host "The system is Awake and running."}
}
}
}
尝试一下:
前提是你要能ping 通