Find Maximum Resolution of display in WMI query

I need to gather the maximum screen resolution for monitors and compare that to what resolution they are currently set at. Getting the currently set resolution is already available via the Windows Hardware Information. I found this PowerShell script online that gets the pertinent info but I wanted to do a native relevance call if possible. In addition I don’t need all the caption results just the numbers (in this case 2560 x 1440).

$MaxResolution = (
Get-WmiObject -Class CIM_VideoControllerResolution) | Select-Object -last 1 -Property Caption, HorizontalResolution, VerticalResolution

Write-Host $MaxResolution

Results in:

@{Caption=2560 x 1440 x 4294967296 colors @ 60 Hertz; HorizontalResolution=2560; VerticalResolution=1440}

I was able to write this in a relevance query however it displays ALL the resolutions. I just need the last one in the list/array which is the maximum available.

if (exists wmi) then (concatenation "; " of ((string value of property "HorizontalResolution" of it & " x " & string value of property "VerticalResolution" of it) of select objects "* from CIM_VideoControllerResolution" of wmi as string)) else "n/a"

I answered my own question. Here is the final query to grab the max resolution:

if (exists wmi) then (following text of last "; " of concatenation "; " of ((string value of property "HorizontalResolution" of it & " x " & string value of property "VerticalResolution" of it) of select objects "* from CIM_VideoControllerResolution" of wmi as string)) else "n/a"

There maybe other ways but as a starter, would this work? Maybe its not the quickest but then again querying WMI often isn’t

Q: (following text of last "|" of concatenation "|" of (preceding texts of lasts "x" of string values of selects "caption from CIM_VideoControllerResolution" of wmi)) as trimmed string
A: 1920 x 1200
T: 600.022 ms
I: singular string
1 Like

Yes this works too thanks!