PowerShell Multiline string


Example

There are multiple ways to create a multiline string in PowerShell:

  • You can use the special characters for carriage return and/or newline manually or use the NewLine-environment variable to insert the systems "newline" value)

    "Hello`r`nWorld"
    "Hello{0}World" -f [environment]::NewLine
    
  • Create a linebreak while defining a string (before closing quote)

    "Hello
    World"
    
  • Using a here-string. This is the most common technique.

    @"
    Hello
    World
    "@