Skip to content

Instantly share code, notes, and snippets.

@mwjcomputing
Last active December 3, 2021 14:54
Show Gist options
  • Save mwjcomputing/114042f37089208b5c562705fe966fec to your computer and use it in GitHub Desktop.
Save mwjcomputing/114042f37089208b5c562705fe966fec to your computer and use it in GitHub Desktop.
Sets the Windows 11 theme between Dark and Light.
function Set-WindowsTheme {
param (
[ValidateSet("light","dark")]
[Parameter(Mandatory=$true)]
[string] $Mode
)
if ('dark' -eq $Mode) {
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 0 -Type Dword -Force
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -Value 0 -Type Dword -Force
} elseif ('light' -eq $Mode) {
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 1 -Type Dword -Force
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -Value 1 -Type Dword -Force
}
<#
.SYNOPSIS
Sets the Windows 11 System Theme
.DESCRIPTION
Sets the Windows 11 System Them to either Dark or Light.
.EXAMPLE
PS C:\> Set-WindowsTheme -Mode light
Sets the Windows 11 Theme to light mode.
.EXAMPLE
PS C:\> Set-WindowsTheme -Mode dark
Sets the Windows 11 Theme to dark mode.
.INPUTS
System.String. The mode of either light or dark that the system theme should be set to.
.OUTPUTS
None
.NOTES
Written by Matthew Johnson (@mwjcomputing)
.LINK
https://mwjcomputing.com
.LINK
https://gist.github.com/mwjcomputing/114042f37089208b5c562705fe966fec
#>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment