Displaying Monitor Model and Resolution

I am trying to come up with a script to give me the monitor(s) model and resolution. I found this script that gives the model and serial and works great.

$ComputerName = 'PC1'
Get-WmiObject -Namespace root\wmi -ClassName wmimonitorid -ComputerName $ComputerName | foreach {
	New-Object -TypeName psobject -Property @{
        Manufacturer = ($_.ManufacturerName -notmatch '^0$' | foreach {[char]$_}) -join ""
        Name = ($_.UserFriendlyName -notmatch '^0$' | foreach {[char]$_}) -join ""
        Serial = ($_.SerialNumberID -notmatch '^0$' | foreach {[char]$_}) -join ""
    }
}

I want to have the resolution in there as well but do not believe I can get the resolution from wmimonitorid. I know there are other classnames that have the resolution(s) but I am not sure how to incorporate it into the code above, especially if there are multiple monitors.

Thanks,
Scott

Hello,

You can try with this:

Add-Type -AssemblyName System.Windows.Forms

$monitor=Get-WmiObject -Namespace root\wmi -ClassName wmimonitorid -ComputerName localhost 
$resolution=[System.Windows.Forms.Screen]::AllScreens

for ($i=0; $i -lt  $monitor.Count; $i++) {
	New-Object -TypeName psobject -Property @{
        Manufacturer = ($monitor[$i].ManufacturerName -notmatch '^0$' | foreach {[char]$_}) -join ""
        Name = ($monitor[$i].UserFriendlyName -notmatch '^0$' | foreach {[char]$_}) -join ""
        Serial = ($monitor[$i].SerialNumberID -notmatch '^0$' | foreach {[char]$_}) -join ""
        Resolution = $resolution[$i].WorkingArea
    }
}

Hope this helps,
BR!

Closest I could get is this

Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorId |
foreach {
   
  $filter = ("InstanceName = '$($psitem.InstanceName)'").Replace("`\", "`\`\")
    
  $maxres = Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorListedSupportedSourceModes -Filter $filter |
  Select-Object -ExpandProperty MonitorSourceModes | 
  Sort-Object -Property {$_.HorizontalActivePixels * $_.VerticalActivePixels} -Descending |
  Select-Object -First 1
  
  if ($psitem.UserFriendlyNameLength -gt 0) {
    $name = ($psitem.UserFriendlyName -notmatch '^0$' | foreach {[char]$_}) -join ""
  }
  else {
    $name = 'Unknown'
  }

  $props = [ordered]@{
     Manufacturer = ($psitem.ManufacturerName -notmatch '^0$' | foreach {[char]$_}) -join ""
     Name = $name
     Serial = ($_.SerialNumberID -notmatch '^0$' | foreach {[char]$_}) -join ""
     MaximumResolution = "$($maxres.HorizontalActivePixels) x $($maxres.VerticalActivePixels)"
  }
  
  New-Object -TypeName PSObject -Property $props  

}

Results look like this

Manufacturer Name    Serial       MaximumResolution
------------ ----    ------       -----------------
GSM          22EA63  304NDJX51788 1920 x 1080      
LEN          Unknown 0            1600 x 900