{"id":2780,"date":"2013-10-03T00:01:00","date_gmt":"2013-10-03T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/10\/03\/use-powershell-to-discover-multi-monitor-information\/"},"modified":"2013-10-03T00:01:00","modified_gmt":"2013-10-03T00:01:00","slug":"use-powershell-to-discover-multi-monitor-information","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/use-powershell-to-discover-multi-monitor-information\/","title":{"rendered":"Use PowerShell to Discover Multi-Monitor Information"},"content":{"rendered":"<p><strong>Summary<\/strong>: Microsoft Scripting Guy, Ed Wilson, talks about how to use Windows PowerShell to discover multi-monitor configuration information on your computer.&nbsp;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/>&nbsp;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&nbsp;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.<\/p>\n<p>&mdash;BG<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/>&nbsp;Hello BG,<\/p>\n<p>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 <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a> is really important because this is where I get many of my ideas for posts.<\/p>\n<p>So BG, thank you for writing.<\/p>\n<p>There are a couple of WMI classes that provide information about resolution and monitors. One of these classes is the <strong>Win32_VideoController<\/strong> class. I can query this by using <strong>Get-CimInstance<\/strong> in Windows PowerShell&nbsp;3.0, or I can use <strong>Get-WmiObject<\/strong> in Windows&nbsp;7 with the default Windows PowerShell&nbsp;2.0. The command is shown here:<\/p>\n<p style=\"padding-left: 30px\">Get-WmiObject win32_videocontroller<\/p>\n<p>Following is the command and its associated output:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6813.HSG-10-3-13-01.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6813.HSG-10-3-13-01.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<p>By looking at the output, I can see that I am most interested in the caption, and in the <strong>CurrentHorizontalResolution<\/strong> and <strong>CurrentVerticalResolution<\/strong> properties. I write the query this way:<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; Get-WmiObject win32_videocontroller | select caption, CurrentHorizontalResolution, CurrentVerticalResolution<\/p>\n<p>The command and its output are as follows:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6215.HSG-10-3-13-02.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6215.HSG-10-3-13-02.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<p>The cool thing is that I can use a wildcard character and the alias and really shorten this command as shown here:<\/p>\n<p style=\"padding-left: 30px\">GWMI win32_videocontroller | select caption, Current*Resolution<\/p>\n<p>So, I have discovered that I have two video controllers on my computer, but both of them are set to use the same resolution.<\/p>\n<p>Well, what about monitors?<\/p>\n<p>To find information about the monitors, I use the <strong>Win32_Desktopmonitor<\/strong> WMI class. The query is shown here:<\/p>\n<p style=\"padding-left: 30px\">Get-WmiObject win32_desktopmonitor<\/p>\n<p>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:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7801.HSG-10-3-13-03.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7801.HSG-10-3-13-03.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<p>Of course, I already have some of this information from the Video Controller. So I can sort of work back and forth with this.<\/p>\n<p>There is a cool WMI class on my laptop running Windows&nbsp;8 (I&rsquo;m not sure if it exists on Windows&nbsp;7 devices). It is in the Root\\WMI namespace. The class is <strong>WmiMonitorBasicDisplayParams<\/strong>, and it tells me if a display is active. It also tells me the capabilities of that monitor. Using the <strong>Get-CimInstance<\/strong> cmdlet produces a nice output (but you can also use <strong>Get-WmiObject<\/strong>). Here is the command:<\/p>\n<p style=\"padding-left: 30px\">Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorBasicDisplayParams<\/p>\n<p>The command and the output are shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6201.HSG-10-3-13-04.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6201.HSG-10-3-13-04.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<p>The <strong>SupportedDisplayFeatures<\/strong> 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:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4118.HSG-10-3-13-05.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4118.HSG-10-3-13-05.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<p>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.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><strong>Ed Wilson, Microsoft Scripting Guy<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about how to use Windows PowerShell to discover multi-monitor configuration information on your computer.&nbsp; &nbsp;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 [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[456,3,4,45,6],"class_list":["post-2780","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-basic-hardware-information","tag-scripting-guy","tag-scripting-techniques","tag-windows-powershell","tag-wmi"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about how to use Windows PowerShell to discover multi-monitor configuration information on your computer.&nbsp; &nbsp;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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2780","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=2780"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2780\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=2780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=2780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=2780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}