Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.