question

lkubler-2593 avatar image
0 Votes"
lkubler-2593 asked IanXue-MSFT commented

Query all monitors on a computer?

Hi,

I'm trying to figure out how to determine how many and what size monitors are connected to a computer running remotely at home, preferably using PowerShell at this moment. Following a Hey Scripting Guys blog post I've hit upon two approaches using wim32, wim32_VideoController and Wim32_DesktopMonitor. These are nice but they don't list all monitors on a system. Almost all of my users have two monitors at home.

Here's the simple script I'm using:
Get-WmiObject -Class "win32_videocontroller" -Namespace "root\CIMV2" -ComputerName $CompName
Get-WmiObject -Class "win32_desktopmonitor" -ComputerName $CompName

I can deduce the size of the monitor from the screen height/width or horizontal/vertical resolution depending which win32 class I am running.

My problem is that it is only returning information on 1 of the 2 monitors.

Any thoughts on how to get it to return all of the monitors attached to the system? Or, is there a better way to get this information that I haven't seen yet?

Thanks in advance!

windows-server-powershell
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,
Is there any update? Have you got a chance to verify the suggestions?
Please feel free to let us know if more assistance needed.
If the reply is helpful, please "Accept Answer" to help other community members find it easier.

0 Votes 0 ·
SethWH avatar image
0 Votes"
SethWH answered
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered IanXue-MSFT edited

Hi,

This command will return all the monitors for you

 Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams

Use PowerShell to Discover Multi-Monitor Information
https://devblogs.microsoft.com/scripting/use-powershell-to-discover-multi-monitor-information/

Best Regards,
Ian
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.