PoshCode Archive  Artifact Content

Artifact 9484d0f73ad08f9cf7dd2d9cf24470d50ea2ad5656bab1f62df2aa439d2d6b40:

  • File Sync-Time.ps1 — part of check-in [1682dd4255] at 2018-06-10 12:56:28 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: 1121
# x-archived: 2017-04-08T23:49:45
# x-published: 2010-05-21T10:01: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)
}