PowerShell script to set the scale of all the connected monitors to 100% in system context

Sreekanth N Kartha 60 Reputation points
2025-10-07T05:31:05.65+00:00

Require a PowerShell script to set the scale of all the connected monitors to 100% in system context.

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

1 answer

Sort by: Most helpful
  1. Tracy Le 1,480 Reputation points Independent Advisor
    2025-10-07T07:18:18.1833333+00:00

    Hello Kartha,

    Display scaling is a user-specific setting, so to apply it system-wide, the script needs to modify the registry for all current and future users on the machine. It will iterate through all currently loaded user profiles to apply the setting immediately for logged-in users and will also modify the default user profile, ensuring any new user who logs onto the machine will inherit this setting.

    You can prefer to set 100% Scaling with PowerShell Script:

    # This script sets the display DPI scaling to 100% (96 DPI) for all users.
    # It must be run with elevated privileges (as Administrator or SYSTEM).
    function Set-DpiScaling {
        param(
            [string]$RegistryPath,
            [int]$DpiValue = 96 # 96 DPI corresponds to 100% scaling
        )
        try {
            $desktopPath = Join-Path -Path $RegistryPath -ChildPath "Control Panel\Desktop"
            $metricsPath = Join-Path -Path $desktopPath -ChildPath "WindowMetrics"
            # Ensure the registry paths exist before trying to set properties
            if (Test-Path -Path $desktopPath) {
                # Set legacy scaling values for compatibility
                Set-ItemProperty -Path $desktopPath -Name "Win8DpiScaling" -Value 1 -Type DWord -Force -ErrorAction Stop
                Set-ItemProperty -Path $desktopPath -Name "LogPixels" -Value $DpiValue -Type DWord -Force -ErrorAction Stop
            }
            if (Test-Path -Path $metricsPath) {
                # Set modern scaling value
                Set-ItemProperty -Path $metricsPath -Name "AppliedDPI" -Value $DpiValue -Type DWord -Force -ErrorAction Stop
            }
            Write-Host "Successfully applied DPI settings to path: $RegistryPath"
        }
        catch {
            Write-Warning "Could not apply DPI settings to '$RegistryPath'. Error: $($_.Exception.Message)"
        }
    }
    # --- Step 1: Apply to all currently logged-in users ---
    Write-Host "Applying settings for currently loaded user profiles..."
    $loadedSids = Get-ChildItem "Registry::HKEY_USERS" | Where-Object { $_.Name -like "*S-1-5-21-*" } | ForEach-Object { $_.PSChildName }
    foreach ($sid in $loadedSids) {
        $userHivePath = "Registry::HKEY_USERS\$sid"
        Set-DpiScaling -RegistryPath $userHivePath
    }
    # --- Step 2: Apply to the Default User Profile for all future users ---
    Write-Host "Applying settings to the Default User Profile..."
    try {
        # Load the default user hive from its file location
        reg load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" | Out-Null
        Set-DpiScaling -RegistryPath "Registry::HKEY_USERS\DefaultUser"
    }
    catch {
        Write-Warning "Failed to load or modify the Default User registry hive. Error: $($_.Exception.Message)"
    }
    finally {
        # CRITICAL: Always unload the hive, regardless of success or failure
        reg unload "HKU\DefaultUser" | Out-Null
    }
    Write-Host "Script execution complete. A reboot or user logoff/logon is required for the changes to take effect."
    

    How to Use This Script:

    1. Save the Script: Copy the code above and save it to a file named Set-Scaling-100.ps1.
    2. Execution in System Context: You can deploy and run this script using management tools like Microsoft Intune or System Center Configuration Manager (SCCM). For manual testing, you can use the psexec tool from Sysinternals to run it as the SYSTEM account:
      • psexec -s -i powershell.exe -ExecutionPolicy Bypass -File "C:\path\to\your\script\Set-Scaling-100.ps1"
      Apply the Changes: For the new scaling settings to be applied, the user must log off and log back on, or the system must be rebooted. This is a necessary step as Windows only reads these registry values during the user session initialization.

    If you find this information helpful and it solves your problem, please feel free to hit "accept answer." It was a pleasure assisting you! 😊

    0 comments No comments

Your answer

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