none
How to get time from Remote computer and compare with DC time. if time difference is more than 5mins send email RRS feed

  • Question

  • Hello Guys,I am looking for a script to get system localtime for all computer in Active directory and Domain computer(where NTP is configured). then show difference. if time difference is more or less than 5mins send email.i did something like this to export to csv but stuck how to invoke time from csv then compare with DC time. Can some one help.

     [CmdletBinding()]
        [OutputType([datetime])]
        param (
            $server
        )
        process {
            $remoteOSInfo = gwmi win32_OperatingSystem -computername $server   
            [datetime]$remoteDateTime = $remoteOSInfo.convertToDatetime($remoteOSInfo.LocalDateTime)   
            return $remoteDateTime
        }

    }

    output in csv: "computer time"

    • Moved by Bill_Stewart Friday, July 27, 2018 9:21 PM This is not "scripts on demand"
    Friday, June 1, 2018 5:49 PM

All replies

  • Please post your code correctly. Use the code posting tool provided.


    \_(ツ)_/

    Friday, June 1, 2018 5:55 PM
  • This is how to detect time sync failures at any system in the enterprise.

    Get-WinEvent -FilterHashtable @{Logname='System';ID=35,36} -ComputerName ws701 -Max 10

    You will see successful syncs about once every 3 days.  Warnings are normal but should not be continuous

    You want at least one successful sync every 5 days.  This will guarantee the time is within a few seconds.


    \_(ツ)_/

    Friday, June 1, 2018 6:26 PM