PowerShell Strings Multiline string

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

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
    "@
    


Got any PowerShell Question?