Solved

Powershell: undecipherable localized output in a remote session

Posted on 2013-01-27
4
1,001 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
No one else provided a solution
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

743 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

16 Experts available now in Live!

Get 1:1 Help Now