If you run
Out-File -InputObject “A” -FilePath “test.txt”you will get both a BOM at the start of the file and a windows-newline at the end of the file. The same happens with Set-Content.
How can I prevent this from happening? What is the best way to output a string, and only the string, to a file?
If your string is plain ASCII I’ve noticed that you could do this in PowerShell5 (no -NoNewline in PowerShellS4)
Out-File -InputObject “A” -FilePath “test.txt” -Encoding “ascii” -NoNewlinebut this does not help much if you have something outside of ASCII.