something exciting

Some information about the exciting thing

Table of contents generated with markdown-toc


function Get-TimeServer {
        Gets the time server as configured on a computer.
        Gets the time server as configured on a computer.
        The default is localhost but can be used for remote computers.
        Get-TimeServer -ComputerName "Server1"
        Get-TimeServer -ComputerName "Server1","Server2"
        Get-TimeServer -Computer "Server1","Server2"
        Get-TimeServer "Server1","Server2"
        Written by Jeff Wouters.
    param (
        [parameter(mandatory = $true, position = 0)]
    begin {
        $HKLM = 2147483650
    process {
        foreach ($Computer in $ComputerName) {
            $TestConnection = Test-Connection -ComputerName $Computer -Quiet -Count 1
            $Output = New-Object -TypeName psobject
            $Output | Add-Member -MemberType 'NoteProperty' -Name 'ComputerName' -Value $Computer
            $Output | Add-Member -MemberType 'NoteProperty' -Name 'TimeServer' -Value "WMI Error"
            $Output | Add-Member -MemberType 'NoteProperty' -Name 'Type' -Value "WMI Error"
            if ($TestConnection) {
                try {
                    $reg = [wmiclass]"\\$Computer\root\default:StdRegprov"
                    $key = "SYSTEM\CurrentControlSet\Services\W32Time\Parameters"
                    $servervalue = "NtpServer"
                    $server = $reg.GetStringValue($HKLM, $key, $servervalue)
                    $ServerVar = $server.sValue -split ","
                    $Output.TimeServer = $ServerVar[0]
                    $typevalue = "Type"
                    $type = $reg.GetStringValue($HKLM, $key, $typevalue)
                    $Output.Type = $Type.sValue
                catch {
            else {
Get-TimeServer -ComputerName $Server.Name

Back to Top


Please feel free to copy parts of the script or if you would like to download the entire script, simple click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.

Report Issues

You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.


Back to Top