Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for getres.ps

(view source code of getres.ps as plain text)

  1. # Remote computer argument for Windows only, not for Linux
  2. param( [string]$computer = "." )
  3.  
  4. if ( $HOME[0] -eq "/" ) {
  5. 	# Linux
  6. 	# Command line argument is ignored.
  7. 	# Less info than Windows' WMI version.
  8.  
  9. 	# xrandr/Select-String tip by diegows on StackOverflow.com
  10. 	# http://superuser.com/a/418700
  11. 	$info = ( xrandr | Select-String -Pattern "\*" ) -split "\s+"
  12.  
  13. 	Write-Host "DeviceName       : "
  14. 	Write-Host "PelsWidth        : " ( $info[1] -split "x" )[0]
  15. 	Write-Host "PelsHeight       : " ( $info[1] -split "x" )[1]
  16. 	Write-Host "BitsPerPel       : "
  17. 	Write-Host "DisplayFrequency : " ( $info[2] -split "\*" )[0]
  18. 	Write-Host
  19. } else {
  20. 	# This PowerShell code for Windows was generated using the WMI Code Generator, Version 10.0 RC3
  21. 	# http://www.robvanderwoude.com/wmigen.php
  22.  
  23. 	$instances = Get-WMIObject -Class "Win32_DisplayConfiguration" -Namespace "root/CIMV2" -Computername $computer
  24.  
  25. 	foreach ( $item in $instances ) {
  26. 		Write-Host "DeviceName       : " $item.DeviceName
  27. 		Write-Host "PelsWidth        : " $item.PelsWidth
  28. 		Write-Host "PelsHeight       : " $item.PelsHeight
  29. 		Write-Host "BitsPerPel       : " $item.BitsPerPel
  30. 		Write-Host "DisplayFrequency : " $item.DisplayFrequency
  31. 		Write-Host
  32. 	}
  33. }
  34.  

page last modified: 2024-04-16; loaded in 0.0058 seconds