Skip to content

Instantly share code, notes, and snippets.

@crbyxwpzfl
Last active February 21, 2022 11:35
Show Gist options
  • Save crbyxwpzfl/e3956fdff8824d168354199bf238115e to your computer and use it in GitHub Desktop.
Save crbyxwpzfl/e3956fdff8824d168354199bf238115e to your computer and use it in GitHub Desktop.
powershell switch windows theme

powershell one liner toggle windows theme.ps1

reg query "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"  /v SystemUsesLightTheme | 
Select-Object -first 3 | 
Select-Object -last 1 | 
%{
   if($_ -match "0x1"){
       New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -Value 0 -Type Dword -Force;
       New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 0 -Type Dword -Force
   }
   else{
       New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -Value 1 -Type Dword -Force;
       New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 1 -Type Dword -Force
   }
}

Allow scripts to run in powersehell for current user

Set-ExecutionPolicy -Scope CurrentUser remotesigned

see execution policies

Get-ExecutionPolicy -List

revert to original polecies

Set-ExecutionPolicy -Scope CurrentUser Restricted

measure script run time

Measure-Command { .\do_something.ps1 | Out-Default }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment