Skip to content

Instantly share code, notes, and snippets.

@joasch
Last active August 17, 2016 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joasch/d38dd56e382bd0f457157ac75634a5c3 to your computer and use it in GitHub Desktop.
Save joasch/d38dd56e382bd0f457157ac75634a5c3 to your computer and use it in GitHub Desktop.
Abfragefunktion für NTP, Auswertung der deutschen w32tm Ausgabe
#ibjs.net 20160817 Abfragefunktion für NTP, Auswertung der deutschen w32tm Ausgabe
$NTP_Server=@("ptbtime1.ptb.de", "ptbtime2.ptb.de", "ptbtime3.ptb.de", `
"pool.ntp.org","europe.pool.ntp.org","de.pool.ntp.org ",`
"time-a.nist.gov","time-b.nist.gov ")
Function Get-NtpTime{
Param($Server)
If (! $Server){$Server="ptbtime1.ptb.de"}
$NTPResponse={(iex "w32tm /stripchart /computer:$Server /dataonly /samples:0")[2]}
$NTPTime={get-date([regex]::Replace("$(&$NTPResponse)","([\D\s]+)([\d\. :]+)\.",'$2'))}
&$NTPTime
}
$NTP_Server|%{"{0,-20}{1}" -f $_,(Get-NtpTime $_)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment