When PS duplicates a CSV file it adds hidden characters at beginning

Why does PS add un-displayable characters to an output file that are not in the original?

Unwanted characters in the header are EF BB BF 0D 0A.

Compare my output file to the CSV input file in HEX. Purpose: If characters match then don’t output that line.

(get-content c:\exports’Receiving Export SAGE.CSV’| select-string -pattern ’ ,0,0,0’ -notmatch) | Out-File c:\Exports’Receiving Export SAGE Zeroes Gone.CSV’ -Encoding utf8

image

Robert,
Welcome to the forum.

First of all … when you post code, error messages, console output or sample data please format it as code using the preformatted text button ( </> ). The picture you posted is almost unreadable.

Thanks in advance.

Is there a special reason why you’re not using Import-Csv and Export-Csv to deal with CSV files?

That’s the the UTF-8 byte order mark. It’s being added because you’re specifying 'Encoding -utf8.