Remove Rogue Keyboard Layout From Windows Session Using PowerShell
Over the years I've been hit by having a US QWERTY keyboard layout added to my Windows session without knowing where it came from.
Today I decided to do something about it.
Using the International PowerShell module, we can get the list of user languages using the Get-WinUserLanguageList PowerShell CmdLet.
In my case (and en-US and pt-PT languages with Portuguese keyboard layout) that will usually be:
LanguageTag : en-US
Autonym : English (United States)
EnglishName : English
LocalizedName : English (United States)
ScriptName : Latin
InputMethodTips : {0409:00000816}
Spellchecking : True
Handwriting : False
LanguageTag : pt-PT
Autonym : Português (Portugal)
EnglishName : Portuguese
LocalizedName : Portuguese (Portugal)
ScriptName : Latin
InputMethodTips : {0816:00000816}
Spellchecking : True
Handwriting : False
However, sometimes I get into this situation:
LanguageTag : en-US
Autonym : English (United States)
EnglishName : English
LocalizedName : English (United States)
ScriptName : Latin
InputMethodTips : {0409:00000816, 0409:00000409}
Spellchecking : True
Handwriting : False
LanguageTag : pt-PT
Autonym : Português (Portugal)
EnglishName : Portuguese
LocalizedName : Portuguese (Portugal)
ScriptName : Latin
InputMethodTips : {0816:00000816}
Spellchecking : True
Handwriting : False
That extra input method can be removed from the list using this PowerShell script:
$WinUserLanguageList = Get-WinUserLanguageList$WinUserLanguageList | Where-Object LanguageTag -eq 'en-US' | ForEach-Object { $WinUserLanguage = $_ $WinUserLanguage.InputMethodTips.Add('0409:00000409') Set-WinUserLanguageList $WinUserLanguageList -Force $WinUserLanguage.InputMethodTips.Clear() $WinUserLanguage.InputMethodTips.Add('0409:00000816') }
Set-WinUserLanguageList $WinUserLanguageList -Force
If you're into one-liners, here it is:
$WinUserLanguageList = Get-WinUserLanguageList; $WinUserLanguageList | ? LanguageTag -eq 'en-US' | % { $WinUserLanguage = $_; $WinUserLanguage.InputMethodTips.Add('0409:00000409'); Set-WinUserLanguageList $WinUserLanguageList -Force; $WinUserLanguage.InputMethodTips.Clear(); $WinUserLanguage.InputMethodTips.Add('0409:00000816') }; Set-WinUserLanguageList $WinUserLanguageList -Force