Link to home
Start Free TrialLog in
Avatar of jnikodym
jnikodym

asked on

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?
Avatar of SubSun
SubSun
Flag of India image

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..
Example..
< Your command > | Export-Csv C:\temp\report.csv -Encoding UTF8 -nti

Open in new window

Avatar of jnikodym
jnikodym

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial