From my past blog posts, I knew that you can configure various regional and language settings using intl.cpl and an xml based answer file. Intl.cpl can be used to set default locale, input locale, GeoID & location preferences and user interface language-related settings. I am not going to go into a lot of detail as it is beyond the scope of today's post; visit support.microsoft.com for a detailed description of the intl.cpl feature set. .
- Create an answer file that contains the regional settings items you wish to configure
- Save it (for example, as C:\temp\MUI.xml)
- Apply the answer file settings using:
control.exe intl.cpl,,/f:"C:\temp\MUI.xml"
I wanted to wrap the configure functionality into an easy to use PowerShell script. As per usual, I am not a fan of reinventing the wheel - there is literally no reason to waste time and develop a solution that might already be available on TechNet or an IT pro's blog. However, a quick Google search yielded no results that provided clear guidance on, so I quickly cobbled together a sample script. Below is the end result:
# Determine where to do the logging $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment $logPath = $tsenv.Value("LogPath") $logFile = "$logPath\$($myInvocation.MyCommand).log" # Create Logfile Write-Output "Create Logfile" > $logFile Function Logit($TextBlock1){ $TimeDate = Get-Date $OutPut = "$ScriptName - $TextBlock1 - $TimeDate" Write-Output $OutPut >> $logFile } # Start Main Code Here $ScriptName = $MyInvocation.MyCommand # Get data $CountryCode = ($env:COMPUTERNAME).Substring(0,2) $RunningFromFolder = $MyInvocation.MyCommand.Path | Split-Path -Parent . Logit "Running from $RunningFromFolder" . Logit "CountryCode variable = $CountryCode" # Create c:\temp if doesn't exist IF (!(Test-Path "C:\temp")) { New-Item -ItemType Directory -Force -Path "C:\temp" } #Generate XML . Logit "Generating MUI.xml file..." #https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-8.1-and-8/hh825682(v=win.10) $xml = @() $xml = '<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
<!-- user list -->
<gs:UserList>
<gs:User UserID="Current" CopySettingsToDefaultUserAcct="true" CopySettingsToSystemAcct="true"/>
</gs:UserList>
<!-- input preferences -->
<gs:InputPreferences>
<gs:InputLanguageID Action="add" ID="0407:00000407"/>
</gs:InputPreferences> </gs:GlobalizationServices>' $xml | Out-File "C:\temp\MUI.xml" #Apply MUI settings $ErrorActionPreference = 'SilentlyContinue' . Logit "Applying MUI settings ... " C:\Windows\System32\control.exe "intl.cpl,,/f:""c:\temp\MUI.xml""" | Out-Null Exit 0
Setting this up is dead simple if you are using MDT. Simply save this script into your deployment share, adjust keyboard ID(s) using this reference table and add a Run PowerShell script step to your TS. That's it!
Below is a somewhat more advanced example which uses computer naming convention to determine machine's location (Germany or Swiss) and to install additional keyboards depending on the result:
# Determine where to do the logging $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment $logPath = $tsenv.Value("LogPath") $logFile = "$logPath\$($myInvocation.MyCommand).log" # Create Logfile Write-Output "Create Logfile" > $logFile Function Logit($TextBlock1){ $TimeDate = Get-Date $OutPut = "$ScriptName - $TextBlock1 - $TimeDate" Write-Output $OutPut >> $logFile } # Start Main Code Here $ScriptName = $MyInvocation.MyCommand # Get data $CountryCode = ($env:COMPUTERNAME).Substring(0,2) $RunningFromFolder = $MyInvocation.MyCommand.Path | Split-Path -Parent . Logit "Running from $RunningFromFolder" . Logit "CountryCode variable = $CountryCode" # Create c:\temp if doesn't exist IF (!(Test-Path "C:\temp")) { New-Item -ItemType Directory -Force -Path "C:\temp" } #Generate XML . Logit "Generating MUI.xml file..." #https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-8.1-and-8/hh825682(v=win.10) $xml = @() $xml = '<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
<!-- user list -->
<gs:UserList>
<gs:User UserID="Current" CopySettingsToDefaultUserAcct="true" CopySettingsToSystemAcct="true"/>
</gs:UserList>
'
If ($CountryCode -eq "CH") {
$xml += '
<!-- input preferences -->
<gs:InputPreferences>
<gs:InputLanguageID Action="add" ID="100c:0000100c"/>
<gs:InputLanguageID Action="add" ID="0810:00000410"/>
<gs:InputLanguageID Action="add" ID="0807:00000807"/>
</gs:InputPreferences>
'
}
Else {
$xml += '
<!-- input preferences -->
<gs:InputPreferences>
<gs:InputLanguageID Action="add" ID="0407:00000407"/>
</gs:InputPreferences>
'
}
$xml += '</gs:GlobalizationServices>' $xml | Out-File "C:\temp\MUI.xml" #Apply MUI settings $ErrorActionPreference = 'SilentlyContinue' . Logit "Applying MUI settings ... " C:\Windows\System32\control.exe "intl.cpl,,/f:""c:\temp\MUI.xml""" | Out-Null Exit 0