How to Change Windows 11 Desktop Background Color with PowerShell?

One of my team members recently asked for a PowerShell script to change the Windows desktop background color. In this tutorial, I will explain how to change the desktop background color in Windows 11 using PowerShell.

Note: You need administrative privileges to run PowerShell scripts on the same machine.

Change Windows 11 Desktop Background Color with PowerShell

Now, let me show you how to change the Windows 11 desktop background color using PowerShell step by step. Follow the below steps:

Step 1: Open PowerShell with Administrative Privileges

First, you need to open PowerShell with administrative privileges. To do this:

  1. Click on the Start menu.
  2. Type “PowerShell” in the search bar.
  3. Right-click on Windows PowerShell and select Run as administrator.

Step 2: Understanding Registry Keys for Desktop Background

Windows stores desktop background settings in the registry. Specifically, the relevant keys are located at:

HKEY_CURRENT_USER\Control Panel\Colors

This registry path contains various settings for colors, including the desktop background color.

Step 3: Changing the Desktop Background Color

To change the desktop background color, you need to modify the Background value within the Colors registry key. Here’s how you can do it with PowerShell:

# Define the registry path
$registryPath = "HKCU:\Control Panel\Colors"

# Define the new background color in RGB format
# Example: Setting the background color to light blue (173, 216, 230)
$newColor = "173 216 230"

# Set the new background color
Set-ItemProperty -Path $registryPath -Name Background -Value $newColor

In this example, the color is set to light blue. You can change the RGB values to any color you prefer.

Step 4: Applying the Changes

After modifying the registry, you need to log out and log back in or restart your computer for the changes to take effect. Alternatively, you can force the system to refresh the desktop settings using PowerShell:

# Refresh the desktop to apply the changes
RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters

Example: Set a Custom Background Color

Let’s say you want to set the background color to a specific shade of green, which is RGB (0, 128, 0). Here’s how you can do it using PowerShell:

# Define the registry path
$registryPath = "HKCU:\Control Panel\Colors"

# Define the new background color in RGB format
$newColor = "0 128 0"

# Set the new background color
Set-ItemProperty -Path $registryPath -Name Background -Value $newColor

# Refresh the desktop to apply the changes
RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters

Check out Rename a Windows Computer Using PowerShell

Troubleshooting Common Issues

Now, let me show you some common issues that you might receive while executing this PowerShell script.

Issue: Changes Are Not Applied

If the changes are not applied, ensure you have administrative privileges and that the registry path is correct. Also, make sure to log out and log back in or restart your computer.

Issue: Incorrect Color Displayed

Double-check the RGB values you entered. Ensure there are no extra spaces or incorrect values. Each component (Red, Green, Blue) should be between 0 and 255.

Change Background Color in Multiple Machines using PowerShell

Sometimes, you might want to change the background color on multiple machines using PowerShell. Here’s an example script that you can deploy across multiple machines:

# PowerShell script to change desktop background color on multiple machines
$computers = @("Computer1", "Computer2", "Computer3") # List of computer names

foreach ($computer in $computers) {
    Invoke-Command -ComputerName $computer -ScriptBlock {
        $registryPath = "HKCU:\Control Panel\Colors"
        $newColor = "0 128 0" # Example: Green color
        Set-ItemProperty -Path $registryPath -Name Background -Value $newColor
        RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters
    }
}
Change Windows 11 Desktop Background Color with PowerShell

Conclusion

In this tutorial, I explained how to change the desktop background color in Windows 11 using PowerShell. I have also explained how to change the desktop background in multiple systems using PowerShell.

You may also like:

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.