locked
UTF8 Encoding Not working RRS feed

  • Question

  • Hi,

    I am facing a problem and i couldn't find any solution online

    I am using Quest Active Roles Management Shell and having problem with Encoding. In My Dev, I am getting the correct data with properly encoded. But when i try the same code in my Production environment, i am not getting it right

    script follows,

    get-content c:\input.txt | Get-QADUser -sizelimit 0 | Select Name, SAMAccountName, Department | Export-CSV C:\output.csv -Encoding UTF8

    Desired Output with encoding will have Portugese charectors like ÃÁÍÇÕÓÔÚÜÀÁ. In dev, it is fine, In Prod , it shows like ����������

    I don't see much difference between my Dev and Prod Environment, But the output file in Dev has Type as "System.Management.Automation.PSObject" where as in production as "Selected.Quest.ActiveRoles.ArsPowerShellSnapIn.Data.ArsUserObject"

    It's a Windows 2008 server in both Dev and Prod

    I don't know what to check..Please help

    Thanks
    Francis

    Wednesday, June 25, 2014 1:18 PM

All replies

  • What happens if you use like this

    get-content c:\input.txt | Get-QADUser -sizelimit 0 | Select Name, SAMAccountName, Department | Out-File -FilePath C:\output.csv -Encoding UTF8

    Let me know. The above code is cranky and don't give required output.

    get-content c:\input.txt | 
    Get-QADUser -sizelimit 0 | Select Name, SAMAccountName, Department | Export-CSV C:\output.csv -NoTypeInformation -Encoding Unicode

    Alternatively you can try


    Regards Chen V [MCTS SharePoint 2010]


    • Edited by Chen VMVP Wednesday, June 25, 2014 2:24 PM
    Wednesday, June 25, 2014 2:16 PM
  • I tried Out-file also. no luck.

    I think the problem is with something else like something related to system setting or Power Shell settings.

    I tried in a different machine too, it didn't work.

    Wednesday, June 25, 2014 3:13 PM
  • Did you tried with Unicode?

    Regards Chen V [MCTS SharePoint 2010]

    Wednesday, June 25, 2014 3:39 PM
  • yes, i did
    Wednesday, June 25, 2014 4:17 PM
  • [System.Text.Encoding]::Default

    Run this code in both DEV and PRD - is similar ?


    Regards Chen V [MCTS SharePoint 2010]

    Wednesday, June 25, 2014 4:24 PM
  • I think there is a problem with the system settings or some service .I am getting the following error in the PRD system when i change the code page to 65001 and ran the command when i try to show the output on the screen itself

    out-lineoutput : The Win32 internal error "A device attached to the system is not functioning" 0x1F occurred when writi
    ng console output buffer at current cursor position. Contact Microsoft Support Services.
        + CategoryInfo          : WriteError: (:) [out-lineoutput], HostException
        + FullyQualifiedErrorId : WriteConsole,Microsoft.PowerShell.Commands.OutLineOutputCommand

    But with default code page or 1252, it shows the result but special chars shown as ????

    Does this help?

    Wednesday, June 25, 2014 5:01 PM
  • Assuming you didn't do any proxy function for Export-CSV .

    What is the PowerShell version? Both in DEV and PRD


    Regards Chen V [MCTS SharePoint 2010]

    Wednesday, June 25, 2014 5:09 PM
  • In PRD, It is ver2.0 and In Dev, It is ver1.0

    Wednesday, June 25, 2014 7:21 PM
  • Not pretty sure and I couldn't replicate it

    Just give a try with below code

    get-content -Encoding UTF8 c:\input.txt | 
    Get-QADUser -sizelimit 0 | Select Name, SAMAccountName, Department | Export-CSV C:\output.csv -Encoding UTF8

    Suspecting something wrong in input format.


    Regards Chen V [MCTS SharePoint 2010]

    Tuesday, July 1, 2014 1:04 PM
  • I tried it, but no luck. still having it
    Monday, July 7, 2014 6:12 PM
  • Just ran into this problem and solved it by selecting a true type font for Windows command prompt under Windows 7.
    • Proposed as answer by Dinfinity Tuesday, September 19, 2017 1:52 PM
    Wednesday, April 12, 2017 7:10 AM
  • Wow, I got the exact same issue and it was also solved by changing the font to a TrueType one in the properties of the powershell window.

    Thank you so much for your comment which helped me a lot!

    Wednesday, January 24, 2018 9:51 AM