WPNinjas HeaderWPNinjas Header

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:

 


if((Get-WinUILanguageOverride -ErrorAction SilentlyContinue) -eq $null){

$false

} else {

$true

}

 

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

 


[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

$objForm = New-Object System.Windows.Forms.Form

$objForm.Size = New-Object System.Drawing.Size(300,220)

$objForm.StartPosition = "CenterScreen"

$objForm.TopMost = $True

$objForm.MaximizeBox = $false;

$objForm.MinimizeBox = $false;

$objForm.KeyPreview = $True

$objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter")

{

$name=$objListbox.SelectedItem;

if($name -eq $null) { $name = "en-US" }

Set-WinUILanguageOverride $name

Set-Culture -CultureInfo de-CH

$objForm.Close()}})

$objListbox = New-Object System.Windows.Forms.ListBox

$objListbox.Location = New-Object System.Drawing.Size(70,20)

$objListbox.Size = New-Object System.Drawing.Size(150,20)

$objListbox.SelectionMode = "One"

$OSInfo = Get-WmiObject -Class Win32_OperatingSystem

$lps = $OSInfo.MUILanguages

foreach($lp in $lps){

[void] $objListbox.Items.Add($lp)

}

$objListbox.SetSelected(0,$True)

$objListbox.Height = 100

$objForm.Controls.Add($objListbox)

$objButton = New-Object System.Windows.Forms.Button

$objButton.Location = New-Object System.Drawing.Size(70,100)

$objButton.Size = New-Object System.Drawing.Size(150,50)

$objButton.Text = "OK"

$objButton.TextAlign = "MiddleCenter"

$objButton.Add_Click({

$name=$objListbox.SelectedItem;

if($name -eq $null) { $name = "en-US" }

Set-WinUILanguageOverride $name

Set-Culture -CultureInfo de-CH

$objForm.Close()})

$objForm.Controls.Add($objButton)

[void] $objForm.ShowDialog()

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

 

</span>

$lps = $OSInfo.MUILanguages

foreach($lp in $lps){

[void] $objListbox.Items.Add($lp)

}

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—

Follow me

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.