Solved

Powershell: undecipherable localized output in a remote session

Posted on 2013-01-27
4
1,049 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
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…

820 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