Set timezone automatically

This commit is contained in:
Manuel Thalmann 2024-08-10 15:17:21 +02:00
parent 99dd620cc8
commit d62ea6ffaa

View file

@ -451,10 +451,17 @@ $null = New-Module {
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" -Name "RealTimeIsUniversal" -Value 1 -Type "DWord"; Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" -Name "RealTimeIsUniversal" -Value 1 -Type "DWord";
# Force time resynchronization # Force time resynchronization
$timeZoneOption = "Start";
$timeZoneKey = "HKLM:\SYSTEM\CurrentControlSet\Services\tzautoupdate";
$service = Get-Service W32Time; $service = Get-Service W32Time;
$autoUpdate = Get-ItemProperty $timeZoneKey -Name $timeZoneOption;
$stopped = ($service.Status -eq "Stopped"); $stopped = ($service.Status -eq "Stopped");
$setUpdate = { param([int] $Value) Set-ItemProperty $timeZoneKey -Name $timeZoneOption $Value };
& $setUpdate 3;
Start-Service $service; Start-Service $service;
w32tm /resync /force; w32tm /resync /force;
& $setUpdate $autoUpdate;
if ($stopped) { if ($stopped) {
Stop-Service $service; Stop-Service $service;