Complex Simplicity

Simple solutions for complex problems.

Configuring time zone and region settings

In Microsoft Intune, it is possible to configure the time zone and region settings using a Settings Catalog. However, using this method locks these settings for the end users, removing their option to change them later. Therefore, I prefer to configure these settings without a Settings Catalog. This approach allows end users the flexibility to modify the settings while still ensuring a consistent default is maintained for all devices.

During a Windows AutoPilot deployment, specifically when a device is enrolling, we can leverage a Win32 application to modify the default user settings. We achieve this by using a PowerShell script containing the following cmdlets:

  • Set-TimeZone
  • Set-WinHomeLocation
  • Set-Culture

After creating this script, we can package it as a Win32 app (.intunewin) and assign it to the targeted devices. I will not go into detail on how to create the Win32 application package. However, we need to package the following PowerShell files for the install and uninstall process (please adjust the scripts if necessary, as they are currently configured for the Netherlands).

install.ps1

# Enable verbose logging to generate a bit more logging
$VerbosePreference = "Continue"

### Create a location for a logfile and start a transcript
$logLocation = Join-Path -Path $Env:SystemDrive -ChildPath "ProgramData\comsim"

# Check if the logLocation is present, if not create it.
if(!(Test-Path $logLocation)){
    New-Item -ItemType Directory -Path $logLocation -Force
}
# Create a name for the logfile
$logName = (Get-Date).ToString("yyMM.ddHH") + "_install_timezoneregion.log"
$logFullName = Join-Path -Path $logLocation -ChildPath $logName

# Start the logging/transcript
Start-Transcript -Path $logFullName

# Configure the default time zone
Set-TimeZone -id "W. Europe Standard Time"  # For possible id options please refer to: https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones?view=windows-11

# Lets check if we can update the timezone by using Location services 
Set-Service -Name tzautoupdate -StartupType Automatic # Set the timezone autoupdate service to Automatic
Start-Service -Name tzautoupdate # Start the service, setting it to Automatic does not start it

# Now lets set the default Home and Culture locations (Region)
# For a full list of GeoId's please check: https://learn.microsoft.com/en-us/windows/win32/intl/table-of-geographical-locations
# For a full list of CultureInfo please check (Language/region tag): https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/available-language-packs-for-windows?view=windows-11
Set-WinHomeLocation -GeoId "176" # Set the country or region to The Netherlands
Set-Culture -CultureInfo "nl-NL" # Set the regional format to The Netherlands
# Copy settings into both the Welcome screen and system accounts, and new user accounts
Copy-UserInternationalSettingsToSystem -WelcomeScreen $true -NewUser $true

# Create a registry key for the Intune Detection rules
New-Item "HKLM:\SOFTWARE\comsim\" -Force | New-ItemProperty -Name "timezoneregion" -Type String -Value "1"

# Stop the logging
Stop-Transcript

Exit 3010 # Exit with an 3010 to indicate that a reboot is required for the settings to take effect.

uninstall.ps1

# Enable verbose logging to generate a bit more logging
$VerbosePreference = "Continue"

### Create a location for a logfile and start a transcript
$logLocation = Join-Path -Path $Env:SystemDrive -ChildPath "ProgramData\comsim"

# Check if the logLocation is present, if not create it.
if(!(Test-Path $logLocation)){
    New-Item -ItemType Directory -Path $logLocation -Force
}
# Create a name for the logfile
$logName = (Get-Date).ToString("yyMM.ddHH") + "_uninstall_timezoneregion.log"
$logFullName = Join-Path -Path $logLocation -ChildPath $logName

# Start the logging/transcript
Start-Transcript -Path $logFullName

# Create a registry key for the Intune Detection rules
Remove-Item "HKLM:\SOFTWARE\comsim\" -Name "timezoneregion" -Force

# Stop the logging
Stop-Transcript

After creating the intunewin32 app we can them upload it to Microsoft Intune and assign them to the device devices. We will need to add the app using the following options:

Program
Install command: %SystemRoot%\Sysnative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File .\install.ps1
Unistall command: %SystemRoot%\Sysnative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File .\uninstall.ps1
Install behavior: SYSTEM

Detection
Rule type: Registry
Key path: HKEY_LOCAL_MACHINE\SOFTWARE\comsim\
Value name: timezoneregion
Operator: Equals
Value: 1
Associated with a 32-bit app on 64-bit clients: No

Note: Do not use abbreviations for the registry hives (such as HKLM and HKCU), Microsft Intune won’t detect the hive.

…and that is it, if enrolled through Windows AutoPilot new users will have a default region and timezone setup with the option to change it.