Allow changing Windows Language during device Enrollment

The management of language packs and keyboard layouts can be very complex. I have seen that in a lot of projects. Often there is the requirement to preconfigure the computer with the correct language pack for the user.
In old school ConfigMgr environments this is controlled often during the task sequence and some TS variables. The configuration and logic is often a time consuming process. In general there are the following problems:

  • Use the built-in Feature of Windows to allow a user to change the language: A normal user is not a local administrator and therefore cannot install a language pack.
  • If you have to include all the language packs in the base image, it will grow and makes inplace upgrades more complex.
  • A deployment over Intune is not possible and in ConfigMgr it requires recreating the packages with each Windows version.

At the moment I work only in modern managed environments without ConfigMgr, which forced me to find new ways to configure per user settings on a device. Windows Autopilot is a great start, but just allows a few settings. Therefore, I created the Advanced Autopilot App, which is launching in full screen and is available on Syntaro. One possible step for the end user, is setting the correct language according to the choice of the end user. The script will set the chosen language with an override, which will really force the system to use this language. If it is not available the language pack will be downloaded from the internet.

The detection script will check if an override is already defined:

 

</p>
<p>if((Get-WinUILanguageOverride -ErrorAction SilentlyContinue) -eq $null){</p>
<p>$false</p>
<p>} else {</p>
<p>$true</p>
<p>}</p>
<p>

 

The following code will create a Window with a list of all available languages.

 

</p>
<p>[void] [System.Reflection.Assembly]::LoadWithPartialName(&quot;System.Drawing&quot;)</p>
<p>[void] [System.Reflection.Assembly]::LoadWithPartialName(&quot;System.Windows.Forms&quot;)</p>
<p>$objForm = New-Object System.Windows.Forms.Form</p>
<p>$objForm.Size = New-Object System.Drawing.Size(300,220)</p>
<p>$objForm.StartPosition = &quot;CenterScreen&quot;</p>
<p>$objForm.TopMost = $True</p>
<p>$objForm.MaximizeBox = $false;</p>
<p>$objForm.MinimizeBox = $false;</p>
<p>$objForm.KeyPreview = $True</p>
<p>$objForm.Add_KeyDown({if ($_.KeyCode -eq &quot;Enter&quot;)</p>
<p>{</p>
<p>$name=$objListbox.SelectedItem;</p>
<p>if($name -eq $null) { $name = &quot;en-US&quot; }</p>
<p>Set-WinUILanguageOverride $name</p>
<p>Set-Culture -CultureInfo de-CH</p>
<p>$objForm.Close()}})</p>
<p>$objListbox = New-Object System.Windows.Forms.ListBox</p>
<p>$objListbox.Location = New-Object System.Drawing.Size(70,20)</p>
<p>$objListbox.Size = New-Object System.Drawing.Size(150,20)</p>
<p>$objListbox.SelectionMode = &quot;One&quot;</p>
<p>$OSInfo = Get-WmiObject -Class Win32_OperatingSystem</p>
<p>$lps = $OSInfo.MUILanguages</p>
<p>foreach($lp in $lps){</p>
<p>[void] $objListbox.Items.Add($lp)</p>
<p>}</p>
<p>$objListbox.SetSelected(0,$True)</p>
<p>$objListbox.Height = 100</p>
<p>$objForm.Controls.Add($objListbox)</p>
<p>$objButton = New-Object System.Windows.Forms.Button</p>
<p>$objButton.Location = New-Object System.Drawing.Size(70,100)</p>
<p>$objButton.Size = New-Object System.Drawing.Size(150,50)</p>
<p>$objButton.Text = &quot;OK&quot;</p>
<p>$objButton.TextAlign = &quot;MiddleCenter&quot;</p>
<p>$objButton.Add_Click({</p>
<p>$name=$objListbox.SelectedItem;</p>
<p>if($name -eq $null) { $name = &quot;en-US&quot; }</p>
<p>Set-WinUILanguageOverride $name</p>
<p>Set-Culture -CultureInfo de-CH</p>
<p>$objForm.Close()})</p>
<p>$objForm.Controls.Add($objButton)</p>
<p>[void] $objForm.ShowDialog()</p>
<p>

In this case I used the languages, which are already installed in the image, but you can also add any other languages:

 

&lt;/span&gt;</p>
<p>$lps = $OSInfo.MUILanguages</p>
<p>foreach($lp in $lps){</p>
<p>[void] $objListbox.Items.Add($lp)</p>
<p>}</p>
<p>

You can find a full list of available script snippets for the enrollment app here: https://wiki.syntaro.com/index.php?title=Enrollment_App_Examples

But the Script can also be used in ConfigMgr with the feature announced in the TP 1711 to allow interaction during application installation which is explained here: https://docs.microsoft.com/en-us/sccm/core/get-started/capabilities-in-technical-preview-1711#allow-user-interaction-when-installing-an-application—-1356976—

Thomas Kurth
Follow me

Thomas Kurth

Principal Workplace Consultant at baseVISION AG
I’m a consultant, trainer and architect for workplace management and enterprise mobility projects with Microsoft Technologies in the past eight years. I love to push and design the modern workplace based on Windows 10, EM&S and O365 for my customers which is the only answer for the current security threats, agile world and the fast-changing business requirements of my customers. Important for me is to simplify and automate the operational processes, because there are the highest costs.

MCSEMCTCMCE
Thomas Kurth
Follow me