Exploring Device Management.
02 January 2025
When purchasing a new device with a different Windows language installed, sometimes the device has a wrong time after the setup. This can be an issue when you dont know that the displayed time is not correct. So this post will tell you how you can fix that in an very smart way with Microsoft Intune to ensure that the time is correct right with the Autopilot deployment.
So without further introduction lets see how we can fix the Windows time – dynamically based on the devices location.
As is wrote we want to change the time based on the devices location and enforce it to change to the correct time zone. For that of course we need the location services within Windows to be enabled. This can simply be done with an Settings catalog profile with „Allow Location“ to be turned on:
You can disable, allow or enforce allow location services. I will enforce allow it on my devices here.
So now that we have the device enabled to use its location we need to tell it to use this for the time zone settings. Therefore I created a small Intune Remediation that enables the „tzautoupdate“ service and cunfigures it in the Windows registry to use the location as an indicator.
So all we need to do is create a new remediation and add the below detection and remediation script there:
Detection
$service = Get-Service -Name tzautoupdate -ErrorAction Stop
$service_running = $service.Status -eq 4
$service_autostart = $service.StartType -eq 2
$autotimezoneenabled = ((Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\tzautoupdate).Start) -eq "3"
if ($service_running -and $service_autostart -and $autotimezoneenabled) {
exit 0
} else {
exit 1
}
Remediation
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\tzautoupdate -Name Start -Value "3"
Set-Service -Name tzautoupdate -StartupType Automatic -PassThru -ErrorAction Stop | Start-Service -ErrorAction Stop
Deploy that remediation to your Entra ID device group and the time will be fixed automatically. If you deploy it on a schedule the device will update the time zone when traveling.
In case that you want to check if and how often this remediation is running you can use the build-in Overview from the remediation as needed.
Dealing with time zone settings on Windows endpoints don’t have to be a huge task. I got inspired from how this works on iOS devices to I checked if there is something similar on Windows and found that service plus its registry configuration. This helped me to add dynamic into Windows time settings without the user or helpdesk needing to fix that manually. But check with your IT security department because some companys dont want location services to be enabled.