< Back

Get-NtpTime

Sat Jan 18, 2020 5:20 pm

NAME Get-NtpTime



SYNOPSIS

Gets (Simple) Network Time Protocol time (SNTP/NTP, rfc-1305, rfc-2030) from a specified server





SYNTAX

Get-NtpTime [[-Server] <String>] [[-MaxOffset] <Int32>] [-NoDns] [<CommonParameters>]





DESCRIPTION

This function connects to an NTP server on UDP port 123 and retrieves the current NTP time.

Selected components of the returned time information are decoded and returned in a PSObject.





PARAMETERS

-Server <String>

The NTP Server to contact. Uses pool.ntp.org by default.



Required? false

Position? 1

Default value pool.ntp.org

Accept pipeline input? false

Accept wildcard characters? false



-MaxOffset <Int32>

The maximum acceptable offset between the local clock and the NTP Server, in milliseconds.

The script will throw an exception if the time difference exceeds this value (on the assumption

that the returned time may be incorrect). Default = 10000 (10s).



Required? false

Position? 2

Default value 10000

Accept pipeline input? false

Accept wildcard characters? false



-NoDns [<SwitchParameter>]

(Switch) If specified do not attempt to resolve Version 3 Secondary Server ReferenceIdentifiers.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

A PSObject containing decoded values from the NTP server. Pipe to fl * to see all attributes.





-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-NtpTime uk.pool.ntp.org



Gets time from the specified server.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-NtpTime | fl *



Get time from default server (pool.ntp.org) and displays all output object attributes.











RELATED LINKS