dantpro icon

ext-ntp-time-src-ad.ps1

dantpro | PRO | 01/19/16 02:29:07 AM UTC | 0 ⭐ | 426 👁️ | Never ⏰ | []
PowerShell |

1.71 KB

|

None

|

0 👍

/

0 👎

# Setting external time source in AD
# https://richardspowershellblog.wordpress.com/2016/01/18/setting-external-time-source-in-ad/
 
##
## set external time source
## set server type to NTP
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters -Name Type -Value 'NTP'
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Config -Name AnnounceFlags -Value 5
 
## Enable NTP server
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer -Name Enabled -Value 1
 
## Specify Time source
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters -Name NtpServer -Value '0.ru.pool.ntp.org,0x1'
 
## Set poll interval in seconds - every 30 minutes
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient -Name SpecialPollInterval -Value 1800
 
## set max +/- time corrections in seconds - 24 hours
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Config -Name MaxPosPhaseCorrection -Value 86400
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Config -Name MaxnegPhaseCorrection -Value 86400
 
Stop-Service -Name W32Time
Start-Service -Name W32Time
 
 
#Wait a minute or so and the time will be set correctly.
#Not a job you have to do very often but having the code to do the job reduces the probability of errors
 
#You can view the settings
Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters
Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Config
Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer
Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient

Comments