Powershell: Export-Csv and non-English letters

The Export-Csv cmdlet is a really nice tool if you want to gather info from e.g. Active Directory that you later want to import to Excel. But as you might have noticed it doesn’t play well with non-English letters.

Working in Norway with users from all the Nordic countries means that we have a lot of users i Active Directory who have non-English letters in their names (æ ø å ö ä and so on). Unless you specify which encoding Export-Csv should use they will show in the csv as ?.

The magical switch to Export-Csv is -encoding. E.g. for us we would use unicode as encoding as this will export the Nordic letters:

Export-Csv <filename> -Encoding unicode

 

 

 

 

 

 

Category(s): Microsoft, Powershell
Tags: , , ,

2 Responses to Powershell: Export-Csv and non-English letters

    Sebastian says:

    -encoding default worked for me. It refused to import the CSV when using unicode

      Subodh Kumar Das says:

      Hi Sebastian,

      You can use UTF format like
      $DT_CandidateData | Export-Csv $extractFile -Encoding UTF8

Leave a Reply to Sebastian Cancel reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.