Author Posts

April 12, 2015 at 8:10 am


I have a reporting system that generates a csv file that I need to import into powershell.

While looking at the file it looks fine , But using import-csv some "special character " is detected in of of the proprieties. Is there anyway to remove this character : �

here is the output
Classification : CMS/NBS � Report � Revision

it should be

Classification : CMS/NBS » Report – Revision

April 12, 2015 at 9:27 am

One option would be to replace the characters:

$Content = Get-Content -Path C:\My\test.csv
$Content = $Content.Replace('»','>').Replace('–','-')
$Csv = ConvertFrom-Csv -InputObject $Content

April 12, 2015 at 9:50 am

Those are extended characters, not ASCII, which is probably causing the problem. You might try using -Encoding to specify the type of encoding (since it isn't ASCII) that the file was created in. For example, "-Encoding UTF8," if that's what was used to create the file.

April 12, 2015 at 3:29 pm

Thanks Guys. -Encoding was the issue.