Solved

Powershell: undecipherable localized output in a remote session

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to dynamically set the form action using jQuery.

809 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