PoshCode Archive  Artifact [f28cc61493]

Artifact f28cc61493e71222cc09f9c49ffa045e773fdbcfe345904468470c15b060a0e9:

  • File Sync-Time.ps1 — part of check-in [13922b9727] at 2018-06-10 13:36:30 on branch trunk — Syncs the system time with that of a remote time server. Uses NetCmdlets. (user: boggers size: 637)

# encoding: ascii
# api: powershell
# title: Sync-Time
# description: Syncs the system time with that of a remote time server.  Uses NetCmdlets.
# version: 0.1
# type: function
# author: boggers
# license: CC0
# function: sync-time
# x-poshcode-id: 4103
# x-archived: 2015-10-27T12:38:11
# x-published: 2015-04-12T17:48:00
#
#
function sync-time(
[string] $server = "sync-time 0.pool.ntp.org, clock.psu.edu",
[int] $port = 37)
{
  $servertime = get-time -server $server -port $port -set
  #leave off -set to just check the remote time
  write-host "Server time:" $servertime 
  write-host "Local time :" $(date)
}