{"id":3150,"date":"2023-11-20T09:42:33","date_gmt":"2023-11-20T09:42:33","guid":{"rendered":"https:\/\/blog.designed79.co.uk\/?p=3150"},"modified":"2023-11-20T09:43:25","modified_gmt":"2023-11-20T09:43:25","slug":"windows-time-sync-registry-set-up","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=3150","title":{"rendered":"Windows Time Sync Registry set Up"},"content":{"rendered":"\n<p>This script needs to be run as an administrator and it will modify registry.<br>The primary domain controller will sync time externally from pool.ntp.org while the seconday dc&#8217;s will sync time from the primary (which has PDc emulater role.)<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:10px\">\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;height:300px;\"><div class=\"text codecolorer\">&amp;lt;# <br \/>\nWindows Time Sync Registry set up <br \/>\nBy allenage.com DC time sync v 0.1<br \/>\nFinal Update on 6\/19\/2017<br \/>\n<br \/>\n<br \/>\n##########################****** Configuration Info *********####################################<br \/>\n# Peers<br \/>\nHKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\W32Time\\Parameters\\NTPServer=pool.ntp.org,0x1<br \/>\nWe are setting Pool.ntp.org,0x1 Check your region if you would set your own http:\/\/www.pool.ntp.org\/zone\/@<br \/>\n<br \/>\n# interval<br \/>\n0x01 SpecialInterval<br \/>\n0x02 UseAsFallbackOnly<br \/>\n0x04 SymmetricActive<br \/>\n0x08 Client<br \/>\n0x9 which uses DNS round robin to make a random selection from a pool of time servers.<br \/>\n<br \/>\n<br \/>\n# For PDC Announce flag 5 and backup domain controllers<br \/>\nHKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\W32Time\\Config\\AnnounceFlags=5<br \/>\nThis entry controls whether this computer is marked as a reliable time server. A computer is not marked as reliable unless it is also marked as a time server.<br \/>\n0x00 Not a time server<br \/>\n0x01 Always time server<br \/>\n0x02 Automatic time server<br \/>\n0x04 Always reliable time server<br \/>\n0x08 Automatic reliable time server<br \/>\nThe default value for domain members is 10. The default value for stand-alone clients and servers is 10.<br \/>\n<br \/>\n# HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\W32Time\\Parameters\\Type=NTP<br \/>\nthis entry indicates which peers to accept synchronization from:<br \/>\n<br \/>\nNoSync. The time service does not synchronize with other sources.<br \/>\nNTP. The time service synchronizes from the servers specified in the NtpServer. registry entry.<br \/>\nNT5DS. The time service synchronizes from the domain hierarchy.<br \/>\nAllSync. The time service uses all the available synchronization mechanisms.<br \/>\n<br \/>\n##########################****** Configuration Info *********####################################<br \/>\n<br \/>\n<br \/>\n<br \/>\nImportant psremoting needs to be enabled.<br \/>\n<br \/>\nrun &nbsp;Enable-PSRemoting -Force on PowerShell elevated mode to enable Psremoting.<br \/>\n<br \/>\nThis script needs to be run as an administrator and it will modify registry.<br \/>\nThe primary domain controller will sync time externally from pool.ntp.org while the secondary dc's will sync time from the primary (which has PDc emulator role.)<br \/>\n<br \/>\nLater you can type Dcdiag to check Advertising test.<br \/>\n<br \/>\n#&amp;gt; <br \/>\n<br \/>\n&nbsp;<br \/>\n&nbsp;If (-NOT (&amp;#91;Security.Principal.WindowsPrincipal]&amp;#91;Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(&amp;#91;Security.Principal.WindowsBuiltInRole] &quot;Administrator&quot;))<br \/>\n&nbsp;{ &nbsp; &nbsp;<br \/>\n&nbsp; Write-Host &quot;This script needs to be run As Admin go back and Run as admin&quot; -BackgroundColor red<br \/>\nStart-Sleep -Seconds 5<br \/>\nExit<br \/>\n&nbsp;}<br \/>\n<br \/>\nWrite-host &quot;Enabling Psremoting on this Computer $env:computername&quot; -ForegroundColor Green<br \/>\n<br \/>\nEnable-PSRemoting -Force<br \/>\n<br \/>\nimport-module activedirectory<br \/>\n<br \/>\n$pdc=Get-ADDomainController -Discover -Service PrimaryDC |select -ExpandProperty name<br \/>\n$PDCSYNC = { w32tm \/config \/manualpeerlist:&quot;pool.ntp.org,0x1&quot; \/syncfromflags:manual \/reliable:yes \/update<br \/>\nw32tm \/config \/update<br \/>\nRestart-Service w32time<br \/>\nw32tm \/resync \/rediscover<br \/>\nw32tm \/resync<br \/>\n}<br \/>\n<br \/>\n# Registry Modifications for PDC so It advertise as Time server<br \/>\n$aflags={Set-ItemProperty -path &quot;HKLM:\\system\\CurrentControlSet\\Services\\W32Time\\Config&quot; -Name AnnounceFlags -Value 5 -Type DWord -Force}<br \/>\n$ntp1={Set-ItemProperty -path &quot;HKLM:\\SYSTEM\\CurrentControlSet\\Services\\W32Time\\Parameters&quot; -Name Type -Value NTP &nbsp;-Force }<br \/>\n$Vmic={Set-ItemProperty -path &quot;HKLM:\\SYSTEM\\CurrentControlSet\\Services\\W32Time\\TimeProviders\\VMICTimeProvider&quot; -Name Enabled -Value 0 -Type DWord -Force}<br \/>\n<br \/>\nInvoke-Command -ComputerName $pdc -ScriptBlock $PDCSYNC<br \/>\nInvoke-Command -ComputerName $pdc -ScriptBlock $aflags<br \/>\nInvoke-Command -ComputerName $pdc -ScriptBlock $ntp1<br \/>\nInvoke-Command -ComputerName $pdc -ScriptBlock $Vmic<br \/>\n$dc=Get-ADDomainController -filter * |?{$_.OperationMasterRoles -notcontains 'PDCEmulator'} |select -ExpandProperty name<br \/>\n<br \/>\n# commands for DC to sync from primary<br \/>\n$dcupdate={w32tm \/config \/syncfromflags:domhier \/update}<br \/>\n$advtest1={Set-ItemProperty -path &quot;HKLM:\\SYSTEM\\CurrentControlSet\\Services\\W32Time\\TimeProviders\\VMICTimeProvider&quot; -Name Enabled -Value 0 -Type DWord -Force}<br \/>\n$advtest2={Set-ItemProperty -path &quot;HKLM:\\system\\CurrentControlSet\\Services\\W32Time\\Config&quot; -Name AnnounceFlags -Value 10 -Type DWord -Force}<br \/>\n$ntp2={Set-ItemProperty -path &quot;HKLM:\\SYSTEM\\CurrentControlSet\\Services\\W32Time\\Parameters&quot; -Name Type -Value NT5DS &nbsp;-Force }<br \/>\n$Advtest3={restart-service w32time}<br \/>\n$advtest4={w32tm \/resync \/rediscover}<br \/>\n$advtest5={w32tm \/resync}<br \/>\nif($dc -like '*')<br \/>\n{<br \/>\nInvoke-Command -ComputerName $dc -ScriptBlock $dcupdate<br \/>\nInvoke-Command -ComputerName $dc -ScriptBlock $Advtest1<br \/>\nInvoke-Command -ComputerName $dc -ScriptBlock $Advtest2<br \/>\nInvoke-Command -ComputerName $dc -ScriptBlock $ntp2<br \/>\nInvoke-Command -ComputerName $dc -ScriptBlock $Advtest3<br \/>\nInvoke-Command -ComputerName $dc -ScriptBlock $Advtest4<br \/>\nInvoke-Command -ComputerName $dc -ScriptBlock $Advtest5<br \/>\n}<br \/>\nelse<br \/>\n<br \/>\n{<br \/>\nwrite-host &quot;You have only one domain controller&quot;<br \/>\n}<\/div><\/div>\n\n<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This script needs to be run as an administrator and it will modify registry.The primary domain controller will sync time externally from [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3150","post","type-post","status-publish","format-standard","hentry","category-info-on-tech"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3150"}],"version-history":[{"count":2,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3150\/revisions"}],"predecessor-version":[{"id":3152,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3150\/revisions\/3152"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}