Solved

Powershell: undecipherable localized output in a remote session

Posted on 2013-01-27
4
1,017 Views
Last Modified: 2013-02-05
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.
0
Comment
Question by:PavelTMN
  • 3
4 Comments
 
LVL 18

Expert Comment

by:dj_alik
ID: 38827869
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
0
 
LVL 1

Author Comment

by:PavelTMN
ID: 38829776
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.
0
 
LVL 1

Accepted Solution

by:
PavelTMN earned 0 total points
ID: 38839628
Found out that winrs -r:remote-comp net session does exactly what I need and it uses winrm service just like powershell remoting. Not really a solution I wanted but whatever.
0
 
LVL 1

Author Closing Comment

by:PavelTMN
ID: 38854280
No one else provided a solution
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
A brief introduction to what I consider to be the best editor for PowerShell.
The viewer will learn how to dynamically set the form action using jQuery.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now