Use PowerShell to Discover Multi-Monitor Information

Doctor Scripto

Dr Scripto

Summary: Microsoft Scripting Guy, Ed Wilson, talks about how to use Windows PowerShell to discover multi-monitor configuration information on your computer. 

Hey, Scripting Guy! Question Hey, Scripting Guy! I am a long time reader, but a first time writer. I have been following your blog for years. You are awesome! I have become good at navigating around various WMI classes, but I need to find information about multiple monitors that are connected to my laptop running Windows 7. Ideally, I would like to know if it is connected to only the laptop display, or if there is an added monitor. If I can also find the resolution, it would be awesome.

—BG

Hey, Scripting Guy! Answer Hello BG,

Microsoft Scripting Guy, Ed Wilson, is here. I just got off a LYNC call with my mentee. We were talking about how important our customers are to us. I told him that I simply cannot do my job properly if I do not talk to customers, hear from customers, and speak to customer groups on a regular basis. He is working on a book, and he mentioned that he misses immediate feedback from customers when he is writing. With my blog, I get feedback every day. In fact, I get an email notification when a comment is written to the blog. These comments make the blog better for us all. Also, the email sent to scripter@microsoft.com is really important because this is where I get many of my ideas for posts.

So BG, thank you for writing.

There are a couple of WMI classes that provide information about resolution and monitors. One of these classes is the Win32_VideoController class. I can query this by using Get-CimInstance in Windows PowerShell 3.0, or I can use Get-WmiObject in Windows 7 with the default Windows PowerShell 2.0. The command is shown here:

Get-WmiObject win32_videocontroller

Following is the command and its associated output:

Image of command output

By looking at the output, I can see that I am most interested in the caption, and in the CurrentHorizontalResolution and CurrentVerticalResolution properties. I write the query this way:

PS C:\> Get-WmiObject win32_videocontroller | select caption, CurrentHorizontalResolution, CurrentVerticalResolution

The command and its output are as follows:

Image of command output

The cool thing is that I can use a wildcard character and the alias and really shorten this command as shown here:

GWMI win32_videocontroller | select caption, Current*Resolution

So, I have discovered that I have two video controllers on my computer, but both of them are set to use the same resolution.

Well, what about monitors?

To find information about the monitors, I use the Win32_Desktopmonitor WMI class. The query is shown here:

Get-WmiObject win32_desktopmonitor

The default display shows information about the screen height and screen width. But this information, for some reason, does not appear for my laptop monitor itself. This is shown in the following image:

Image of command output

Of course, I already have some of this information from the Video Controller. So I can sort of work back and forth with this.

There is a cool WMI class on my laptop running Windows 8 (I’m not sure if it exists on Windows 7 devices). It is in the Root\WMI namespace. The class is WmiMonitorBasicDisplayParams, and it tells me if a display is active. It also tells me the capabilities of that monitor. Using the Get-CimInstance cmdlet produces a nice output (but you can also use Get-WmiObject). Here is the command:

Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams

The command and the output are shown here:

Image of command output

The SupportedDisplayFeatures property returns another object. The easy way to look at this is to store the object in a variable, and then address it directly. This technique is shown in the following image:

Image of command output

BG, that is all there is to using Windows PowerShell to find multi-monitoring information. Join me tomorrow when I will talk about more cool Windows PowerShell stuff.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy

2 comments

Comments are closed. Login to edit/delete your existing comments

  • Avatar
    Jan Israelsson

    Hi,
    I need to find additional information (serial number) in order to keep our inventory up to date and not having to manually visit thousands of desks in order to do this. Our standard desk is equipped with a HP 3005pr port replicator (USB) and has a dual monitor setup (DVI and DP on port replicator).
    Has anyone tried (and succeeded…), if so please share your findings.
    Regards,
    Jan

    • Avatar
      Vlad Matsegora

      Hi. I have the the same problem and get solved it (or almost). You can see in results of WmiMonitorBasicDisplayParams query parameter InstanceName that looks like string “DISPLAY\ACR056B\4&3968765c&0&UID50531072_0”. I use it for query to remote PC’s registry, exept 2 chars (“_0”) in the end of string. In registry i go to HKLM\SYSTEM\CurrentControlSet\Enum\(InstanceName of WmiMonitorBasicDisplayParams without “_0”)\Device Parameters. There you can see byte array stored in EDID key. Using EDID i get more info about display. Use wiki for more info about EDID