Link to home
Start Free TrialLog in
Avatar of PavelTMN
PavelTMN

asked on

Powershell: undecipherable localized output in a remote session

I have local and remote systems both with Russian display language. When trying to run a non-powershell command in a remote PS session I get undecipherable strings:
[remote-comp]: PS C:\Users\admin\Documents> net session
' ¿¿¿¿¿? -?¿ ¿<?+?-¿R¿.

Open in new window

The sessions only seem to differ in [Console]::OutputEncoding output.
Remote session:
[remote-comp]: PS C:\Users\admin\Documents> [Console]::OutputEncoding
IsSingleByte      : True
BodyName          : koi8-r
EncodingName      : ¿¿¿¿¿¿¿¿¿ (Windows)
HeaderName        : windows-1251
WebName           : windows-1251
WindowsCodePage   : 1251
IsBrowserDisplay  : True
IsBrowserSave     : True
IsMailNewsDisplay : True
IsMailNewsSave    : True
EncoderFallback   : System.Text.InternalEncoderBestFitFallback
DecoderFallback   : System.Text.InternalDecoderBestFitFallback
IsReadOnly        : True
CodePage          : 1251

Open in new window

Local session:
PS C:\Windows\system32> [Console]::OutputEncoding
IsSingleByte      : True
BodyName          : cp866
EncodingName      : ¿¿¿¿¿¿¿¿¿ (DOS)
HeaderName        : cp866
WebName           : cp866
WindowsCodePage   : 1251
IsBrowserDisplay  : True
IsBrowserSave     : True
IsMailNewsDisplay : False
IsMailNewsSave    : False
EncoderFallback   : System.Text.InternalEncoderBestFitFallback
DecoderFallback   : System.Text.InternalDecoderBestFitFallback
IsReadOnly        : True
CodePage          : 866

Open in new window

All relevant properties seem to be read-only.
How do I fix remote output?
Thank you.
Avatar of dj_alik
dj_alik

PowerShell cmdlets is controlled by the $OutputEncoding variable, which is by default set to ASCII. you can fix this by changing $OutputEncoding to [Console]::OutputEncoding.

PS C:\> $OutputEncoding = [Console]::OutputEncoding

and see PS C:\> $OutputEncoding
Avatar of PavelTMN

ASKER

The problem is not with PowerShell cmdlets. They are shown correctly. It's "old" commands like net session.
PS C:\> $OutputEncoding = [Console]::OutputEncoding
It works but changes seemingly nothing.
ASKER CERTIFIED SOLUTION
Avatar of PavelTMN
PavelTMN

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No one else provided a solution