Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to change the date of a server to the next day then run a sql script and then change the server date back.

I figured out how to change the server date via powershell

Invoke-Command -ComputerName $sql_box_server_name -Credential $credentials -ScriptBlock {Set-Date -date (Get-Date).AddDays(1)}

however when I need to set the date back I get an error stating there is a date/time difference between the server and client. I know this is a AD/Kerberos issue however I'm not sure how to solve it.

I tried setting the machine that runs the script's date to the same as the server however it still gives the error.

Note $credentials is set using Get-Credentials and uses Kerberos by default.

share|improve this question

In my domain controller setup script template I have these two registry injections:

reg ADD "HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config" /t REG_DWORD /v MaxPosPhaseCorrection /d 900 /f
reg ADD "HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config" /t REG_DWORD /v MaxNegPhaseCorrection /d 900 /f

This will reject time adjustments of more than 15 minutes either way, which is much tighter than the default value, if I remember correctly (I've not had any problems doing this so far).

Anyway, if you are able to change these values on the remote computer to something like 172800 (for 48 hours), you should be able to do what you want, I think.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .