PowerShell: Toggle Dark Theme

By Xah Lee. Date: . Last updated: .

Using PowerShell to set dark theme.

put this in your PowerShell Profile

function xah-toggle-darktheme {
    <#
 .DESCRIPTION
 Toggle dark theme
 Version 2022-01-15 2022-06-08
 .LINK
 http://xahlee.info/powershell/powershell_set_darktheme.html
#>
    $xpath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize";
    $xname = "AppsUseLightTheme";
    if ((Get-ItemProperty $xpath -Name AppsUseLightTheme).$xname -eq 1) {
        Set-ItemProperty $xpath -Name $xname -Value 0;
    }
    else {
        Set-ItemProperty $xpath -Name $xname -Value 1;
    }
}

PowerShell

Practical How-To

list files

list dirs

on dir

on file

Windows config

misc


PowerShell in Depth

Programing PowerShell

Value Types

String

Variable

Boolean

Conditional

Data Structure

Loop and Iteration

Input/Output

Function

Profile and Script

Script Examples