Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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