Solved

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

Posted on 2016-10-05
3
45 Views
Last Modified: 2016-10-05
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?
0
Comment
Question by:jnikodym
  • 2
3 Comments
 
LVL 40

Expert Comment

by:Subsun
Comment Utility
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

0
 

Author Comment

by:jnikodym
Comment Utility
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

0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
Comment Utility
Out-File $outFile -Encoding UTF8 Should work..
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now