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:
- Click on the Start menu.
- Type “PowerShell” in the search bar.
- 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\ColorsThis 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 $newColorIn 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,UpdatePerUserSystemParametersExample: 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,UpdatePerUserSystemParametersCheck 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
}
}
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:
- Change Wallpaper with PowerShell
- Disable Local User Computer Accounts Using PowerShell
- How to Keep Your Screen Active with a PowerShell Script?
- Track User Login History on Windows Using PowerShell
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.