May 29 2021 10:21 AM
I have a home laptop to which I have remote ssh access using Powershell. How can I get whether the lid is opened or close
Jan 29 2022 11:02 AM
You can list all currently active displays by using
Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams
Output:
Then you narrow it down to the one you need, in this case my laptop screen is the one with the instance name containing 'LEN40a9'
Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams | Where-Object InstanceName -Match 'LEN40a9'
Then you can determine if it's open or closed by using:
if ((Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams | Where-Object InstanceName -Match 'LEN40a9').Active -eq 'True') {
write-host monitor lis is open} else {
write-host Monitor lid is closed
}
Feb 03 2022 09:58 AM
@Harm_Veenstra
It is very old post. I think I used windows events to solve this that time.