Get lid open or close state using powershell

Copper Contributor

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

4 Replies

@shashwat001 

 

You can list all currently active displays by using 

Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams

Output:
Harm_Veenstra_0-1643482652761.png

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'

Harm_Veenstra_1-1643482770409.png

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
}
Did this work for you?

@Harm_Veenstra 
It is very old post. I think I used windows events to solve this that time.

Ah, that's also an option :)