I have been working on a way that I can ensure the maximum resolution is set on monitors. Every so often, a monitor does not have the resolution set to maximum. I have been trying to figure out a way to set the resolution to maximum for more than a year, especially when a system is built in the build room and then moved to the user's office to be setup with new monitors. The problem I have had was being able to get the maximum resolution value. It is not stored in the system that is easily accessible through PowerShell. I had thought about having the script go through the keystroke process of the Display screen to set the monitor resolution to maximum and then write the resolution values to a text file. PowerShell can retrieve the resolution monitors are currently set to. Finally, it occurred to me the maximum resolution should be stored in the INF driver file. I opened up the file and there it was.
Andy Schneider has this awesome script that can set the resolution of the monitors. The only part was needed were the resolution values. The script below can be used with Andy's to set the resolution to maximum for each installed monitor. The Get-MaximumResolution function returns an array of objects containing the model, horizontal, and vertical resolutions.
Here is the output of the script after it was executed on my machine that has three monitors.
I also want to point out that SAPIEN's PowerShell Studio made writing the script a breeze. It simplifies the process of this and allows for much more thorough scripting.
The script is available to download from my GitHub site located here.
Andy Schneider has this awesome script that can set the resolution of the monitors. The only part was needed were the resolution values. The script below can be used with Andy's to set the resolution to maximum for each installed monitor. The Get-MaximumResolution function returns an array of objects containing the model, horizontal, and vertical resolutions.
Here is the output of the script after it was executed on my machine that has three monitors.
I also want to point out that SAPIEN's PowerShell Studio made writing the script a breeze. It simplifies the process of this and allows for much more thorough scripting.
The script is available to download from my GitHub site located here.
<#
.SYNOPSIS
Get Maximum Monitor Resolution
.DESCRIPTION
This script will retrieve the maximum possible resolution for monitors by identifying the associated driver. The driver INF file contains the maximum defined resolution for a monitor. This script is designed for Dell monitors only. It has not been tested on any other brand. Also, the monitors need to be installed in the device manager to get the correct association.
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.139
Created on: 5/30/2017 12:37 PM
Created by: Mick Pletcher
Organization:
Filename: MaxResolution.ps1
===========================================================================
#>
[CmdletBinding()]
param ()
function Get-MaximumResolution {
#Create monitor array
$Monitors = @()
#Get associate monitor hardware ID for each monitor
$HardwareIDs = (Get-WmiObject Win32_PNPEntity | where-object { $_.PNPClass -eq "Monitor" }).HardwareID | ForEach-Object { $_.Split("\")[1] }
foreach ($Monitor in $HardwareIDs) {
#Create object
$Object = New-Object -TypeName System.Management.Automation.PSObject
#Get the location of the associated driver file
$DriverFile = Get-ChildItem -path c:\windows\system32\driverstore -Filter *.inf -recurse | Where-Object { (Select-String -InputObject $_ -Pattern $Monitor -quiet) -eq $true }
#Retrieve the maximum resolution from the INF file
$MaxResolution = ((Get-Content -Path $DriverFile.FullName | Where-Object { $_ -like "*,,MaxResolution,,*" }).split('"')[1]).Split(",")
#Write the Model to the object
$Object | Add-Member -MemberType NoteProperty -Name Model -Value $DriverFile.BaseName.ToUpper()
#Write the horizontal maximum resolution to the object
$Object | Add-Member -MemberType NoteProperty -Name "Horizontal(X)" -Value $MaxResolution[0]
#Write the vertical maximum resolution to the object
$Object | Add-Member -MemberType NoteProperty -Name "Vertical(Y)" -Value $MaxResolution[1]
#Write the object to the array
$Monitors += $Object
}
Return $Monitors
}
#Display list of monitor with maximum available resolutions
$Monitors = Get-MaximumResolution
$Monitors
0 comments:
Post a Comment