How-to: Get the display resolution for multiple computers [DisplayRes.ps1]

Get the display resolution for all the computers listed in a text file:

# read in the workstation names
$workstations = get-content "C:\scripts\workstations.txt"

foreach($pc in $workstations)
{
   # Ping the machine to see if it's turned on
   $result = Test-connection "$pc" -quiet
   
   if ($result) {

      # Get the display details via CIM
      $displays= Get-CIMinstance -class "Win32_DisplayConfiguration" -computername $pc
      
      foreach ($display in $displays) {
         $w=$display.PelsWidth
         $h=$display.PelsHeight
         "$pc Width: $w Height: $h"
         "$pc Width: $w Height: $h" >>C:\scripts\DisplayRes.txt
      }

      } else {
            "$pc : Not Responding"
            "$pc : Not Responding" >>C:\scripts\DisplayRes.txt
      }
}
# End

For instructions of how to download and run this script see: Run a PowerShell script.

Examples

Assuming DisplayRes.ps1 is saved in the current directory:

PS C:\scripts\> ./DisplayRes.ps1

“The possession of knowledge does not kill the sense of wonder and mystery. There is always more mystery” ~ Anais Nin

Related PowerShell Cmdlets

pshInfo - List Ram, Disk Space, Service pack, Uptime


 
Copyright © 1999-2024 SS64.com
Some rights reserved