DisplayRes.ps1

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

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

foreach($pc in $workstation_list)
{
   # Ping the machine to see if it's turned on
   $query = "select * from win32_pingstatus where address = '$pc'"
   $result = Get-WmiObject -query $query
   
   if ($result.protocoladdress) {

      # Get the display details via WMI
      $displays= Get-WmiObject -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

Example

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:

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


© Copyright SS64.com 1999-2013
Some rights reserved