Skip to content

Instantly share code, notes, and snippets.

@cbilson
Created February 10, 2016 17:13
Show Gist options
  • Save cbilson/74932807648bc4ff42bb to your computer and use it in GitHub Desktop.
Save cbilson/74932807648bc4ff42bb to your computer and use it in GitHub Desktop.
function Set-WindowsTheme {
param([ValidateSet('Light', 'Dark')] $Value)
foreach ($path in 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize',
'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize')
{
$personalize = if (Test-Path $path) {
Get-Item $path
} else {
New-Item $path
}
$propertyValue = if ($Value -eq 'Light') { 1 } else { 0 }
if ($personalize.PSObject.Properties['AppsUseLightTheme'] -eq $null) {
Set-ItemProperty -Path $path -Name AppsUseLightTheme -Value $propertyValue
} else {
New-ItemProperty -Path $path -Name AppsUseLightTheme -Value $propertyValue -PropertyType DWORD |
Out-Null
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment