Created
June 13, 2018 08:10
-
-
Save denim2x/5d733fa1d054c527f49537dc7919a06e to your computer and use it in GitHub Desktop.
PowerShell cmdlet for setting Night Light on WIndows 10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Set-BlueLight { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory=$true)] [ValidateRange(0, 23)] [int]$StartHour, | |
[Parameter(Mandatory=$true)] [ValidateSet(0, 15, 30, 45)] [int]$StartMinutes, | |
[Parameter(Mandatory=$true)] [ValidateRange(0, 23)] [int]$EndHour, | |
[Parameter(Mandatory=$true)] [ValidateSet(0, 15, 30, 45)] [int]$EndMinutes, | |
[Parameter(Mandatory=$true)] [bool]$Enabled, | |
[Parameter(Mandatory=$true)] [ValidateRange(1200, 6500)] [int]$NightColorTemperature | |
) | |
$data = (2, 0, 0, 0) | |
$data += [BitConverter]::GetBytes((Get-Date).ToFileTime()) | |
$data += (0, 0, 0, 0, 0x43, 0x42, 1, 0) | |
If ($Enabled) {$data += (2, 1)} | |
$data += (0xCA, 0x14, 0x0E) | |
$data += $StartHour | |
$data += 0x2E | |
$data += $StartMinutes | |
$data += (0, 0xCA, 0x1E, 0x0E) | |
$data += $EndHour | |
$data += 0x2E | |
$data += $EndMinutes | |
$data += (0, 0xCF, 0x28) | |
$tempHi = [Math]::Floor($NightColorTemperature / 64) | |
$tempLo = (($NightColorTemperature - ($tempHi * 64)) * 2) + 128 | |
$data += ($tempLo, $tempHi) | |
$data += (0xCA, 0x32, 0, 0xCA, 0x3C, 0, 0) | |
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount\$$windows.data.bluelightreduction.settings\Current' -Name 'Data' -Value ([byte[]]$data) -Type Binary | |
} |
Here's one updated for Windows 11 22H2: https://github.com/nathanbabcock/nightlight-cli
The most sophisticated tool to date to control Night Light: https://github.com/Enyium/sem-reg-rs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Similarly - Set-BlueLight