Set timezone automatically
This commit is contained in:
parent
99dd620cc8
commit
d62ea6ffaa
1 changed files with 7 additions and 0 deletions
|
@ -451,10 +451,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;
|
||||
|
|
Loading…
Reference in a new issue