Microsoft - TimeZone and Language
Configuring the time zone using Group Policy
Supported operating systems: Windows 2003/XP and higher, up to and including Windows 10 and Windows Server 2016 (all versions and builds). Supported deployment methods: all, including direct (bare-metal) installations and image-based deployments using technologies such as Citrix Machine Creation Services (MCS) and Citrix Provisioning Services (PVS). |
This section deals with the configuration of the time zone settings. On a local machine, these are configured in the Date & Time settings. Time zone settings are system-specific and not configured per-user (although you can redirect the local time zone in a remote session).
The time zone configuration is stored in the Windows registry in the HKEY_LOCAL_MACHINE hive. The exact registry key is:
HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
The time zone settings consist of multiple values as seen in the screenshot below.
To find out the exact value for each of the ten registry entries, first set the time zone manually in the local Date & Time configuration. Afterwards, simply check the aforementioned registry values.
Note: all available time zones are also listed in the registry in the key HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. |
Open your Group Policy Management Console (GPMC.msc) and navigate to Computer Configuration \ Preferences \ Windows Settings \ Registry. Since we need to import multiple values, I suggest to use the registry wizard. With a right-mouse click on Registry select New \ Registry Wizard.Now that we have all the information we need, we can set the correct time zone for the local machine. The easiest way to accomplish this is by using a Group Policy Preference registry item. And no, unfortunately there is no native out-of-the-box group policy setting or preference to configure the time zone. This goes for all Windows operating systems.
On the first page of the wizard, make sure that Local Computer is selected and click Next. On the second tab, the Registry Browser, navigate to the registry key HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation. Tick the box of each individual registry value (as shown in the image below). Use the scroll bar on the right to go down in the list. Unfortunately, there is no Select All option (@Microsoft: HINT!).
Click Finish. The registry values have been imported.
If you are unhappy with the organisation of the registry items, you can easily move the individual settings (in the blue box) to a new collection item.
First, we need to create a new collection item (this is basically a folder). With a right-mouse click on Registry select New \ Collection Item. Enter a name for the collection item, for example TimeZone. Now you can move all individual registry items to this new collection item per drag-and-drop.
Afterwards, you can delete the collection item named Registry Wizard Values (all underlying folders are automatically deleted as well).
The registry item is now created and will be deployed to all machines to which the particular Group Policy applies.
Note: by default, the value name is used as the name of the registry item (as is visible in the image above). It is possible to rename the registry item afterwards, but please be aware that whenever you make changes to the registry item, it’s name will revert back to the value name. |
After configuring the time zone, restart the machine to allow the changes to take effect.
Configuring the time zone using PowerShell
Supported operating systems: Windows 7 / Windows Server 2008 R2 and higher, up to and including Windows 10 and Windows Server 2016 (all versions and builds), with PowerShell 5.1 installed (this is a requirement!). |
For those of you who want to include the configuration of the time zone in a PowerShell script, the cmdlet Set-TimeZone can be used. The basic command is as follows:
1
|
Set-TimeZone -Id "W. Europe Standard Time"
|
In case the time zone does not exist, an error is returned, which is great when using a try/catch statement. In the example below, I deliberately misspelled the time zone W. Europe Standard Time to force an error:
1
2
3
4
5
6
7
|
[string]$TimeZone = "W. Europe Standard Timeeeeeeee"
try {
Set-TimeZone -Id $TimeZone
Write-Host "Success: the time zone $TimeZone has been set"
} Catch {
Write-Host "Error: the time zone $TimeZone does not exist!"
}
|
The Set-TimeZone cmdlet is included in PowerShell 5.1 and, exceptionally, not restricted to the newest operating systems. This cmdlet also works on Windows 7 and Windows Server 2008 R2. PowerShell 5.1 is included in the Windows Management Framework 5.1.
Note: running the Set-TimeZone PowerShell command as a startup script may end in error 5 “access denied”. At least that is what happened when I tested it on a server running Windows Server 2016 version 1607. I do not know why this happened, especially since the group policy is executed by the local system account. |
One drawback of using this method (I can’t believe I am about to say something against using PowerShell) is that the time zone will be hard-coded in the image. In case the time zone needs to be changed, you will have to do one (or more) of the following:
- Update the master image.
- Update each machine to which the master image was deployed. This only applies to direct (bare-metal) installations. In case you use deployment technologies such as Citrix Machine Creation Services (MCS) or Citrix Provisioning Services (PVS), you will have to update the master image and re-deploy it.
- Use a Group Policy to change the time zone. This is the most flexible way to manage time zone settings on a multitude of machines.
Configuring the time zone using tzutil.exe
Supported operating systems: Windows 2003/XP and higher, up to and including Windows 10 and Windows Server 2016 (all versions and builds). |
Besides the PowerShell cmdlet, Microsoft also offers the on-board utility tzutil.exe to configure the time zone. This tool has been part of the Windows operating system since Windows XP and Server 2003. Here is an example how to set the time zone to Western-Europe Standard Time:
tzutil /s “W. Europe Standard Time”
One drawback of using this method is that the time zone will be hard-coded in the image. Changing the time zone at a later time requires you to do one (or more) of the following:
- Update the master image.
- Update each machine to which the master image was deployed. This only applies to direct (bare-metal) installations. In case you use deployment technologies such as Citrix Machine Creation Services (MCS) or Citrix Provisioning Services (PVS), you will have to update the master image and re-deploy it.
- Use a Group Policy to change the time zone. This is the most flexible way to manage time zone settings on a multitude of machines.
Redirecting the time zone of the local client in remote sessions
In case you have users that connect from a different time zone than the server time zone, in remote sessions, you have the option to redirect the local time zone:
Microsoft Remote Desktop Services
For Remote Desktop Sessions, you can enable a Microsoft group policy that redirects the time zone of the local client. You can find this policy here:
Computer Configuration \ Administrative Templates \ Windows Components \ Remote Desktop Services \ Remote Desktop Session Host \ Device and Resource Redirection -> Allow time zone redirection
Citrix Virtual Apps and Desktops (CVAD) / XenDesktop
For Citrix (ICA) sessions you can configure the policy Use local time of client to redirect the local time zone to the remote server.
Configuring the code page using Group Policy
Supported operating systems: Windows 2003/XP and higher, up to and including Windows 10 and Windows Server 2016 (all versions and builds). Supported deployment methods: all, including direct (bare-metal) installations and image-based deployments using technologies such as Citrix Machine Creation Services (MCS) and Citrix Provisioning Services (PVS). |
This section deals with the configuration of the code page (system locale) of the local system. The code page controls the language the system uses for non-unicode programs. On a local machine, the code page is configured on the third tab, Administrative, of the Regional Settings Control Panel item. The code page is system-specific (not configured per-user).
Note: in Windows, the code page is referred to as system locale. I am not in agreement with this, because the system locale also includes other components such as the display language (the Windows language) and the default input language (the keyboard layout) for the system user. These settings determine what a user sees at the Windows logon window (CTRL+ALT+DEL). In therefore in this article use the word code page and not system locale. |
The code page setting is stored in the Windows registry in the HKEY_LOCAL_MACHINE hive. The exact registry key and value are:
HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language -> Default (REG_SZ)
Please be aware that the value Default is not the same as the (Default) value present in every registry key. The code page is stored in the value Default, so this one:
Not this one:
To determine the country ID, change the code page manually on your local system. On the local system, open the Regional Settings in the Control Panel. The code page (system locale) can be changed on the third tab. After changing the code page, you will be asked to reboot the system. This is not necessary. The registry value Default containing the code page setting has already been modified. Go to the registry and check your country ID.
For example, when I set the code page to German (Austria), the value Default is set to 0c07. Before it was 0409, which is the country ID for the United States.
Now that we have all the information we need we can set the correct code page for the local machine. The easiest way to accomplish this is by using a Group Policy Preference registry item.
Open your Group Policy Management Console (GPMC.msc) and navigate to Computer Configuration \ Preferences \ Windows Settings \ Registry. With a right-mouse click on Registry select New \ Registry Item. Configure the registry item as follows:
- Action: replace
- Hive: HKEY_LOCAL_MACHINE
- Key path: SYSTEM\CurrentControlSet\Control\Nls\Language
- Value name: Default
- Data type: REG_SZ (= string)
- Value data: <your value>, e.g. 0c07 or 0409
The registry item is now created and will be deployed to all machines to which the particular Group Policy applies.
Note: by default, the value name is used as the name of the registry item (as is visible in the image above). It is possible to rename the registry item afterwards, but please be aware that whenever you make changes to the registry item, it’s name will revert back to the value name. |
After configuring the code page, restart the machine to allow the changes to take effect.