Windows editors, including ISE, tend to use a carriage return followed by linefeed ( or `r`n) at the end of each line. Linux editors use linefeed only ( or `n).
Line endings are less important if the only thing reading the file is PowerShell (on any platform). However, if a script is set to executable on Linux, a sha-bang must be included and the line-ending character used must be linefeed only.
For example, a created as follows named test.ps1 must use to end lines:
#!/usr/bin/env powershell Get-Process
The first line is the sha-bang and lets Linux know which parser to use when executing the shell script.
Once created, chmod may be used to make the script executable outside of PowerShell:
chmod +x test.ps1
After being made executable, the script may be executed from bash with the full path or a relative path:
./test.ps1
PowerShell ISE uses carriage return followed by line feed ( ). This behavior is by design and cannot be changed.
Visual Studio Code uses for line endings by default. This may be changed in User Settings by adding the following command:
"files.eol": " "