Forum Discussion
shashwat001
May 29, 2021Copper Contributor
Get lid open or close state using powershell
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
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 }
- Did this work for you?
- shashwat001Copper Contributor
Harm_Veenstra
It is very old post. I think I used windows events to solve this that time.- Ah, that's also an option 🙂