From 9daaf4cee8780507572f8a5d0bbd7c544f0dbd75 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 10 Aug 2024 15:17:21 +0200 Subject: [PATCH] Set timezone automatically --- scripts/Windows/OS/Install.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/Windows/OS/Install.ps1 b/scripts/Windows/OS/Install.ps1 index 5b802e77..08f9bc2b 100644 --- a/scripts/Windows/OS/Install.ps1 +++ b/scripts/Windows/OS/Install.ps1 @@ -448,10 +448,17 @@ $null = New-Module { Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" -Name "RealTimeIsUniversal" -Value 1 -Type "DWord"; # Force time resynchronization + $timeZoneOption = "Start"; + $timeZoneKey = "HKLM:\SYSTEM\CurrentControlSet\Services\tzautoupdate"; $service = Get-Service W32Time; + $autoUpdate = Get-ItemProperty $timeZoneKey -Name $timeZoneOption; $stopped = ($service.Status -eq "Stopped"); + + $setUpdate = { param([int] $Value) Set-ItemProperty $timeZoneKey -Name $timeZoneOption $Value }; + & $setUpdate 3; Start-Service $service; w32tm /resync /force; + & $setUpdate $autoUpdate; if ($stopped) { Stop-Service $service;