How to set common resolution for all connected display through PowerShell

Sreekanth N Kartha 60 Reputation points
2025-08-06T14:05:26.22+00:00

Require a PowerShell code that sets all the displays connected including the primary display to a maximum common resolution.

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. gastone canali 241 Reputation points Volunteer Moderator
    2025-08-28T12:48:20.2333333+00:00
    Install-Module DisplayConfig
    Add-Type -AssemblyName System.Windows.Forms
    function Get-CommonResolution {
        $screens = [System.Windows.Forms.Screen]::AllScreens
        $resolutions = @()
        foreach ($screen in $screens) {
            $width = $screen.Bounds.Width
            $height = $screen.Bounds.Height
            $resolutions += "$width x $height"
        }
        # Find the minimum resolution (common denominator)
        $minWidth = ($screens | Measure-Object -Property Bounds.Width -Minimum).Minimum
        $minHeight = ($screens | Measure-Object -Property Bounds.Height -Minimum).Minimum
        return @{ Width = $minWidth; Height = $minHeight }
    }
    function Set-Resolution {
        param (
            [int]$Width,
            [int]$Height
        )
        $mode = "$Width,$Height,32,60"
        $command = "DisplaySwitch.exe /extend"
        Start-Process -FilePath "cmd.exe" -ArgumentList "/c $command" -Wait
        # Use NirCmd or MultiMonitorTool for actual resolution change
        # Example with NirCmd:
        # nircmd.exe setdisplay 1 $Width $Height 32
    }
    # Main
    $commonRes = Get-CommonResolution
    Set-Resolution -Width $commonRes.Width -Height $commonRes.Height"
    
    
    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.