daily pastebin goal
34%
SHARE
TWEET

ext-ntp-time-src-ad.ps1

dantpro Jan 18th, 2016 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Setting external time source in AD
  2. # https://richardspowershellblog.wordpress.com/2016/01/18/setting-external-time-source-in-ad/
  3.  
  4. ##
  5. ## set external time source
  6. ## set server type to NTP
  7. Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters -Name Type -Value 'NTP'
  8. Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Config -Name AnnounceFlags -Value 5
  9.  
  10. ## Enable NTP server
  11. Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer -Name Enabled -Value 1
  12.  
  13. ## Specify Time source
  14. Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters -Name NtpServer -Value '0.ru.pool.ntp.org,0x1'
  15.  
  16. ## Set poll interval in seconds - every 30 minutes
  17. Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient -Name SpecialPollInterval -Value 1800
  18.  
  19. ## set max +/- time corrections in seconds - 24 hours
  20. Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Config -Name MaxPosPhaseCorrection -Value 86400
  21. Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Config -Name MaxnegPhaseCorrection -Value 86400
  22.  
  23. Stop-Service -Name W32Time
  24. Start-Service -Name W32Time
  25.  
  26.  
  27. #Wait a minute or so and the time will be set correctly.
  28. #Not a job you have to do very often but having the code to do the job reduces the probability of errors
  29.  
  30. #You can view the settings
  31. Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters
  32. Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Config
  33. Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer
  34. Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top