⚡ PowerShell 5.1+

Get Connected Monitors Report

Queries Win32_DesktopMonitor via WMI and reports Connected Monitors in a formatted table, with an optional CSV export.

By WindowsScripting.com · 938 B
Get-DesktopMonitorReport.ps1
<#
.SYNOPSIS
    Reports Connected Monitors on this computer via WMI (Win32_DesktopMonitor).

.DESCRIPTION
    Queries Win32_DesktopMonitor and displays Name, ScreenWidth, ScreenHeight for each item found.
    Use -ExportPath to also save the results to a CSV file.

.PARAMETER ExportPath
    Optional path to a .csv file to write the results to.

.EXAMPLE
    .\Get-DesktopMonitorReport.ps1

.EXAMPLE
    .\Get-DesktopMonitorReport.ps1 -ExportPath C:\Reports\desktopmonitor.csv
#>

[CmdletBinding()]
param(
    [string]$ExportPath
)

$items = Get-CimInstance -ClassName Win32_DesktopMonitor | Select-Object Name, ScreenWidth, ScreenHeight

if (-not $items) {
    Write-Host "No Connected Monitors found." -ForegroundColor Yellow
    return
}

$items | Format-Table -AutoSize

if ($ExportPath) {
    $items | Export-Csv -Path $ExportPath -NoTypeInformation -Encoding UTF8
    Write-Host "`nExported to $ExportPath" -ForegroundColor Cyan
}