September 7th, 2014

PowerTip: New Lines with PowerShell

Doctor Scripto
Scripter

Summary: Create new lines with Windows PowerShell.

Hey, Scripting Guy! Question How can I use Windows PowerShell to add a new line between lines for my text output?

Hey, Scripting Guy! Answer Use the `n character, for example:

PS C:\> "string with new line `n in it"

string with new line

 in it

Note  If you need a carriage return, use `r. For a carriage return and a new line, use `r`n.

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

3 comments

Discussion is closed. Login to edit/delete existing comments.

  • Markus Wehr

    How to remember? first r then n like “ReturN”

    • Nikolay Kozhemyak

      Could be more self-describing like Return Newline.

  • Shinish Sasidharan

     `r`n. Works like a charm!! Thanks