Here's a pretty cool script that will get you the monitor size for a local or remote device via WMI. If will work with both single monitor devices as well as multiple monitors.

param($ComputerName = 'localhost')

$output = [PSCustomObject]@{
    ComputerName = $ComputerName
    MonitorSizes = ''
}

$oWmi = Get-WmiObject -Namespace 'root\wmi' -ComputerName $ComputerName -Query "SELECT MaxHorizontalImageSize,MaxVerticalImageSize FROM WmiMonitorBasicDisplayParams"

$sizes = @()
if ($oWmi.Count -gt 1) {
    foreach ($i in $oWmi) {
        $x = [System.Math]::Pow($i.MaxHorizontalImageSize/2.54,2)
        $y = [System.Math]::Pow($i.MaxVerticalImageSize/2.54,2)
        $sizes += [System.Math]::Round([System.Math]::Sqrt($x + $y),0)
    }
} else {
    $x = [System.Math]::Pow($oWmi.MaxHorizontalImageSize/2.54,2)
    $y = [System.Math]::Pow($oWmi.MaxVerticalImageSize/2.54,2)
    $sizes += [System.Math]::Round([System.Math]::Sqrt($x + $y),0)
}
$output.MonitorSizes = $sizes
$output

Join the Jar Tippers on Patreon

It takes a lot of time to write detailed blog posts like this one. In a single-income family, this blog is one way I depend on to keep the lights on. I'd be eternally grateful if you could become a Patreon patron today!

Become a Patron!