The -EncodedCommand requires a Base64-encoded string, but the topics mentioned in the title neglect to mention that the basis for the Base64 encoding can only be a UTF16-LE ("Unicode")-encoded string.
To demonstrate this:
# A sample PowerShell command to pass to the CLI.
$str = '"hi"'
# Base64-encode the string based on its UTF16-LE bytes.
$strEnc64Utf16 = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($str))
# Base64-encode the string based on its UTF8 bytes.
$strEnc64Utf8 = [Convert]::ToBase64String([Text.Encoding]::utf8.GetBytes($str))
# OK: UTF16-LE
pwsh -noprofile -EncodedCommand $strEnc64Utf16
# !! DOESN'T WORK: UTF8
pwsh -noprofile -EncodedCommand $strEnc64Utf8
Ditto for powershell.exe
Version(s) of document impacted