In dealing with data transferred between different operating systems, we often come across the irritating phenomenon of, what might appear as, a file without any spaces in them. This is of course because of different end of line (EOL) characters, and I’m going to show you a quick and easy way of using PowerShell to “fix” these for Windows.
This is a nice example of PowerShell being nice, and doing stuff for us. For instance, when you use Get-Content to read the contents of a text file, even though it’s using NIX-style line endings, PowerShell will automatically detect this and replace it with the appropriate line endings for Windows. This means that we can use the following one-liner to quickly fix a file with foreign EOL:
Get-Content -Path $pathToInputFile | Out-File -FilePath $pathToOutputFile
This will automatically replace the line endings with the proper Windows EOL (CR+LF).