It’s very important to check quickly if there is an issue with the NTP configuration of a Windows Server or Workstation.
This script will help you to perform a quick check on your network, targeting workstation or server if needed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
#Requires -RunAsAdministrator function Get-NTPStatusFromHost{ <# .Synopsis Get NTP status from a host .Description Get the Network Time Protocol (NTP) status from a host. It's a simple a W32tm Wrapper. .Example Get-NTPStatusFromHost -Computername localhost This shows the NTP Status of the localhost, this will be the result: NTP STATUS FOR localhost Leap Indicator: 0(no warning) Stratum: 7 (secondary reference - syncd by (S)NTP) Precision: -6 (15.625ms per tick) Root Delay: 0.0079510s Root Dispersion: 0.3620458s ReferenceId: 0xC0A86302 (source IP: 192.168.0.2) Last Successful Sync Time: 23/05/2017 10:43:37 PM Source: dc1.contoso.com Poll Interval: 15 (32768s) .Example get-adcomputer -searchbase ‘OU=workstations,dc=contoso,dc=com’ -filter * -property * | select name | Get-NTPStatusFromHost This shows the NTP Status for all the workstation in AD. .Notes Author: Paolo Frigo - https://www.scriptinglibrary.com #> Param( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, Position=0)] [Alias('Name')] [string[]]$ComputerName ) Process { write-output "NTP STATUS FOR $ComputerName" w32tm /query /computer:$ComputerName /status } } |
On Linux OS, you can simply run this command on a bash shell:
1 |
ntptime |
You can find this script on my GitHub repository.