Get Count of Connected Monitors on Windows

Get Count of Connected Monitors on Windows

Determining how many displays are currently attached to a Windows system can be helpful for automation tasks, inventory reporting, or managing multi-screen workstations. This tutorial explains how to get the count of connected monitors on Windows.

Windows exposes monitor information through WMI (Windows Management Instrumentation), allowing PowerShell to query display devices. A simple way to obtain the number of monitors currently detected by the operating system is to retrieve active monitor entries and count them.

@(Get-CimInstance WmiMonitorID -Namespace root\wmi | ? Active).Length

Output example:

3

This result indicates that three monitors are currently active and recognized by Windows, including built-in and external monitors.

Now, let's break down this command:

  • Get-CimInstance - retrieves management information from computer.
  • WmiMonitorID - specifies the WMI class containing identification details for display devices detected by Windows.
  • -Namespace root\wmi - directs the query to the WMI namespace where monitor-related information is stored.
  • | ? Active - filters the returned monitor objects and keeps only those whose Active property is set to True, meaning the display is currently in use.
  • @( ... ) - places the filtered results into an array, ensuring that the output can be counted correctly whether one or multiple monitors are present.
  • .Length - returns the number of objects in the array, which corresponds to the total count of active monitors.

Leave a Comment

Cancel reply

Your email address will not be published.