Using PowerShell to change encoding of a .csv file.
Posted: Wed Feb 28, 2018 11:18 pm
I am trying to use PowerShell to change the encoding of a .csv file. This is what I have tried but it's not working.
First Attempt: (this works outside Switch)
Get-ChildItem *.csv | % { (Get-Content $_) | Set-Content "$($_.basename).csv" -encoding ASCII }
Second Attempt:
(Get-Content -Encoding UCS-2 LE BOM $FILENAME ) | Out-File -Encoding ANSI $FILENAME
Third Attempt:
get-content $yourfile | out-file $yourfile -encoding utf8
What am I doing wrong here? Any help would be much appreciated.
First Attempt: (this works outside Switch)
Get-ChildItem *.csv | % { (Get-Content $_) | Set-Content "$($_.basename).csv" -encoding ASCII }
Second Attempt:
(Get-Content -Encoding UCS-2 LE BOM $FILENAME ) | Out-File -Encoding ANSI $FILENAME
Third Attempt:
get-content $yourfile | out-file $yourfile -encoding utf8
What am I doing wrong here? Any help would be much appreciated.