Script to check time on a list of servers and reset any that are wrong RRS feed

  • Question

  • I have a list of Citrix servers that reboot every night. I periodically have issues where some of them have the wrong time and users have application issues on them

    I would like to create script that checks the time on all of these servers in the morning after they reboot and if it finds the time is incorrect to reset the time service to correct the issue.

    I currently do this with 2 manual processes:

    Get Time from Server list

    $servers = gc "c:\Temp\CMHServlst.txt"


    foreach ($server in $servers){

    $dt = gwmi win32_operatingsystem -computer $server

    $dt_str = $dt.converttodatetime($dt.localdatetime)

    write-host "$($server) current local time is $($dt_str)"


    Reset Time on Server List

    $computers = Get-Content “c:\Temp\servers.txt”

    Invoke-Command -ComputerName $computers {Restart-Service W32Time}

    • Moved by Bill_Stewart Wednesday, May 30, 2018 8:49 PM Question outside forum scope
    Wednesday, April 11, 2018 2:14 PM

All replies

  • I recommend fixing the domain time sync as time issues cannot be solved by a reboot.  You can have many problems occur between reboots.

    You either have a configuration error or other domain issues. All time sync is done to the DC.  It must work correctly. Kludging this is not the correct solution.


    Wednesday, April 11, 2018 2:46 PM