ColorMode.psm1

$registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"

function Get-AppsColorMode { Get-ItemProperty -Path $registryPath | % AppsUseLightTheme }

function Get-SystemColorMode { Get-ItemProperty -Path $registryPath | % SystemUsesLightTheme }

function Set-ColorMode
{
  param(
    [parameter(Mandatory=$true)]
    [bool] $Dark
  )

  $appsValue = if ($Dark -eq $true) { 0 } else { 1 }
  New-ItemProperty -Path $registryPath -Name AppsUseLightTheme -Value $appsValue -Type Dword -Force 

  $systemValue = if ($Dark -eq $true) { 0 } else { 1 }
  New-ItemProperty -Path $registryPath -Name SystemUsesLightTheme -Value $systemValue -Type Dword -Force 
}

function Set-DarkMode { Set-ColorMode -Dark $true }

function Set-LightMode { Set-ColorMode -Dark $false }

Export-ModuleMember -Function "Get-*"
Export-ModuleMember -Function "Set-*"