When Executing native cmd command from powershell, e.g net view \\192.168.1.x
I get the following results which non-English chars shown as ????
:
Share name Type Used as Comment
--------------------------------------------------
AntEater Disk
AntEater_Eab Disk
HP M4345 ????? Print HP M4345 ?????
Letters Disk
SMSCenter Disk
temp Disk
Users Disk
????? ??? ?????? Print ????? ??? ??????
The command completed successfully.
if I run chcp 862
I get the following results (on the console):
Share name Type Used as Comment
--------------------------------------------------
AntEater Disk
AntEater_Eab Disk
HP M4345 הנהחש Print HP M4345 הנהחש
Letters Disk
SMSCenter Disk
temp Disk
Users Disk
מדפסת Print
Which is fine, but when I try to save it to a variable or export it to a file:
$temp = net view \\192.168.1.x
$temp
Share name Type Used as Comment
--------------------------------------------------
AntEater Disk
AntEater_Eab Disk
HP M4345 ????? Print HP M4345 ?????
Letters Disk
SMSCenter Disk
temp Disk
Users Disk
????? ??? ?????? Print ????? ??? ??????
the results are wrong again,
I've already tried:
net view \\192.168.1.x | Out-File C:\temp.txt -Encoding Unicode
cmd /c 'chcp 862 && net view \\192.168.1.x' | Out-File C:\temp.txt -Encoding Unicode
cmd /c 'chcp 862 && net view \\192.168.1.x > c:\temp.txt'
cmd /u /c 'chcp 862 && net view \\192.168.1.x > c:\temp.txt'
and much more really...
The Issue shown as well when running net view \\192.168.1.x | Out-String
The same results are whether I run it from CMD or PowerShell
Do you know the behavior? how can I save the correct output to a variable or file?
After changing the "language for non-Unicode programs" in the control panel, the problem solved, thanks for your help...
Run
intl.cpl
and select theAdminstrative
tab.