LanguageTag     : en-US
Autonym         : English (United States)
EnglishName     : English
LocalizedName   : English (United States)
ScriptName      : Latin
InputMethodTips : {0409:00000409}
Spellchecking   : True
Handwriting     : False

Actual behavior

Get-WinUserLanguageList: Cannot marshal 'parameter #2': Invalid managed/unmanaged type combination.

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      7.1.0
PSEdition                      Core
GitCommitId                    7.1.0
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Exception : Type : System.Runtime.InteropServices.MarshalDirectiveException TargetSite : Name : GetUserLanguages DeclaringType : Microsoft.InternationalSettings.Commands.LPAPIWrapper, Microsoft.InternationalSettings.Commands, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 MemberType : Method Module : Microsoft.InternationalSettings.Commands.dll StackTrace : at Microsoft.InternationalSettings.Commands.LPAPIWrapper.GetUserLanguages(Char Delimiter, String& UserLanguages) at Microsoft.InternationalSettings.Commands.GetWinUserLanguageListCommand.ProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() Message : Cannot marshal 'parameter #2': Invalid managed/unmanaged type combination. Source : Microsoft.InternationalSettings.Commands HResult : -2146233035 CategoryInfo : NotSpecified: (:) [Get-WinUserLanguageList], MarshalDirectiveException FullyQualifiedErrorId : System.Runtime.InteropServices.MarshalDirectiveException,Microsoft.Intern ationalSettings.Commands.GetWinUserLanguageListCommand InvocationInfo : MyCommand : Get-WinUserLanguageList ScriptLineNumber : 1 OffsetInLine : 1 HistoryId : 3 Line : Get-WinUserLanguageList PositionMessage : At line:1 char:1 + Get-WinUserLanguageList + ~~~~~~~~~~~~~~~~~~~~~~~ InvocationName : Get-WinUserLanguageList CommandOrigin : Internal ScriptStackTrace : at <ScriptBlock>, <No file>: line 1

Have you tried this to import Windows PowerShell module in WindowsPowerShell mode which is available as a parameter for Import-Module cmdlet? Had same error and had to run this following lines first.

Import-Module -Name International -UseWindowsPowerShell -Verbose

deitry, MINORITYmaN, cfuendev, gnbfilho, danstur, AnrDaemon, chrisfcarroll, protron, ultradumb, and Familex reacted with thumbs up emoji rashil2000, MINORITYmaN, cfuendev, maverom, and twilight-slider reacted with heart emoji All reactions

Have you tried this to import Windows PowerShell module in WindowsPowerShell mode which is available as a parameter for Import-Module cmdlet? Had same error and had to run this following lines first.

Import-Module -Name International -UseWindowsPowerShell -Verbose

Thanks, @stewardjornsen! It executed successfully after running the import.

Is it self-evident that Set-WinUserLanguageList ... and New-WinUserLanguageList en-GB also don't work, or should I raise a separate issue?

This is my code that worked (and still works) in PS5 but doesn't in PS7:

$ll= New-WinUserLanguageList en-GB
$cafeencounterAppleM7903="0809:A0000809" 
$enUSIntl="0809:00020409"; 
$ll[0].InputMethodTips.Add($cafeencounterAppleM7903)
$ll[0].InputMethodTips.Add($enUSIntl)
$ll[0].InputMethodTips.Remove("0809:00000809") | out-null
$ll.Add("el")
$global:ChrisKeyboardList=$ll
function keyboard(){ Set-WinUserLanguageList $global:ChrisKeyboardList -Force}

With errors:

New-WinUserLanguageList: Cannot marshal 'parameter #1': Invalid managed/unmanaged type combination.
Set-WinUserLanguageList: Cannot bind parameter 'LanguageList'. Cannot convert the "Microsoft.InternationalSettings.Commands.WinUserLanguage" value of type "Deserialized.Microsoft.InternationalSettings.Commands.WinUserLanguage" to type "Microsoft.InternationalSettings.Commands.WinUserLanguage".