PowerShell Module for Time Synchronization – Get current time in UTC from internet

This PowerShell Workflow is part of PowerShell module for Time Synchronization on Windows and Windows Server. To get all features you need all PowerShell Workflows from the Time Sync module.

There is no reason to make this script PowerShell Workflow but I decided to write it as Workflow because it is part of other Workflows (of course Advanced Function could be also part of any Workflow).


  • Get current date and time in UTC (Coordinated Universal Time) from the internet.
  • The date and time is obtained from public website over HTTP (TCP 80) so it is possible to use this workflow in environments without direct access to internet (for example over proxy).
  • It is PowerShell Workflow so this script could be for example used via Service Management Automation (SMA) on Microsoft Azure.


Workflow Get-VDateTimeInternetUtc
        Get current date and time for internet.

            Developer: Rudolf Vesely, http://rudolfvesely.com/
            Copyright (c) Rudolf Vesely. All rights reserved
            License: Free for private use only

            "V" is the first letter of the developer's surname. The letter is used to distingue Rudolf Vesely's cmdlets from the other cmdlets.

            Get current date and time for internet.

            Developed and tested using PowerShell 4.0.

        'Get using HTTP'




        HelpURI = 'https://techstronghold.com/',
        ConfirmImpact = 'Medium'

    # Configurations
    $ErrorActionPreference = 'Stop'
    $ProgressPreference = 'SilentlyContinue'

    $webRequest = Invoke-WebRequest -Uri 'http://nist.time.gov/actualtime.cgi?lzbc=siqm9b'

    $milliseconds = [int64](($webRequest.Content -replace '.*time="|" delay=".*') / 1000)

    # Return
        (New-Object -TypeName DateTime -ArgumentList (1970, 1, 1)).AddMilliseconds($Using:milliseconds)

Leave a Reply

Your email address will not be published.