mattiasvdlbe/MS Endpoint Manager/Proactive Remediations/PR_S_TimeAndDateCorrection
Some time ago, we had some devices which were no longer running on the correct time.
On the devices in question the users didn’t have administrator permissions, so they couldn’t change the time and date themselves.
As the end users needed to be able to continue their work as soon as possible, and the issue wasn’t widespread, we decided to just create a small script to fix the issue.
The script shared in this post, is more advanced, and has more options.
If you want to use it, check if all things checked and set in this script are relevant in your case.
This script does some checks to make sure the end user device is using the correct date and time.
Things the proactive remediation checks:
- StartupType of the Windows Time Service is set to “Manual” (which is the default setting)
- Windows Time Service is running
- “Set the time automatically” is activated
- Location use is allowed (Privacy setting).
Location use needs to be allowed if you want to allow the system to automatically detect what time zone your currently in.
- “Set the time zone automatically” is enabled
- Compare NtpServer time and the local computer time.
If there’s a difference of more than 15 seconds either way (ahead or behind)
In case any of these checks fails, the remediation gets triggered, which then puts the system back to our desired configuration.
It also creates a log with some text outputs which are specified in the script.
For this, it uses an implemented function called “Write-Log()”
If you want to use this script, don’t forget to change the log output path.
Other functions which are implemented:
All credits to Tim Curwick for this function.
I’ve only added a While loop to retry retrieving the NtpTime in case it fails the first time around. In case of failure, it retries again after 30 seconds. It can retry at most 2 times.