How to automate the adding & removal of unwanted keyboard layouts.
This is a PowerShell script that does the same as manually adding unwanted keyboards layouts and then removing them. It is still necessary to add them back before installing a list with only the layout you want, or they still will not be removed.
You will need to figure out the language/layout code to add with InputMethodTips.Add()
, if you have multiple layouts under one language. You can find these by adding them manually the first time under 'Language Settings' and finding the codes with Get-WinUserLanguageList
.
# Create a new language list
$l = New-WinUserLanguageList("en-US")
# Add the en-DK layout (which is active but not in the list)
$l[0].InputMethodTips.Add("0409:00000406")
# Add the da language & keyboard (which is active but not in the list)
$l.Add("da-DK")
# Set this list so that they are active and in the list
Set-WinUserLanguageList $l -Force
# Create a new list without the en-DK/da-DK layouts
$l = New-WinUserLanguageList("en-US")
# Set the new list. This will actually remove them!
Set-WinUserLanguageList $l -Force
If you add the unwanted layouts & languages the first time, and then examine the list with Get-WinUserLanguageList
, you can see which input methods (layouts) and langauge you need to add in the script. When you have done this the first time it happens, you can use the script the next time to automatically remove the unwanted layouts.