Powershell Command to create a csv file using UTF-8 encoding

I have a powershell command that is calling a sql query to create a csv file.  The file is being created as encoded as Unicode.  I need the file to be encoded as UTF-8.  Is there a command i can add to my code to have the file created as UTF-8?
Who is Participating?
SubsunConnect With a Mentor Commented:
Out-File $outFile -Encoding UTF8 Should work..
Which command you use to export the details?

If you are using Export-Csv to export the data to csv then you can use the -Encoding parameter..
< Your command > | Export-Csv C:\temp\report.csv -Encoding UTF8 -nti

Open in new window

jnikodymAuthor Commented:
Below is the code that exports the csv file

$outFile = "C:\iqs\customers.csv"
$result = GetSQL $query
$result | ConvertTo-Csv -Delimiter "|" -NoTypeInformation | % {$_.Replace('"','')} | Out-File $outFile

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.