PoshCode Archive  Artifact Content

Artifact 67834af105a6ce774328177508c9da693958ba909f20661d49e1b590c736498a:

  • File Sync-Time.ps1 — part of check-in [a7ad647e6a] at 2018-06-10 13:36:27 on branch trunk — Syncs the system time with that of a remote time server. Uses NetCmdlets. (user: Lance Robinson size: 618)

# 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: Lance Robinson
# license: CC0
# function: sync-time
# x-poshcode-id: 4101
# x-archived: 2017-04-10T08:09:57
# x-published: 2014-04-12T17:47:00
#
#
function sync-time(
[string] $server = "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)
}