$text = """
Line 1
Line 2
Line 3
Line 4
"""
$text -replace "(?m)^\s*`r`n",''
# Or
$text -replace "(?m)^\s*`n",''
объяснение регулярного выражения:
(?m) set the multiline flag so ^ matches the beginning of each line and not just the begining of the whole string.
^ matches the beginning of a line
\s* matches any number of white spaces (could also be 0 white spaces)
`r`n matches the end of a line.
Почему `r`n или просто` n (в зависимости от машины или файла):
\`r = CR (Carriage Return) → Used as a new line character in Mac OS before X
\`n = LF (Line Feed) → Used as a new line character in Unix/Mac OS X
\`r\`n = CR + LF → Used as a new line character in Windows