Suppose I have the a document c:\temp\temp.txt
with contents
line 1
line 2
and I create the following function
PS>function wrapit($text) {
@"
---Start---
$text
---End---
"@
}
Then running PS> wrapit((Get-Content c:\temp\temp.txt))
will output
---Start---
line 1 line 2
---End---
How do I preserve newlines? Appending versus interpolating doesn't help.
I found this related question, but here they are using a string array. I am using a single string which has newline characters in it (you can see them if you output the string directly from inside the function without concatenating and $text | gm
confirms I'm working with a string, not an array). I can do all the string parsing in the world to hammer it into place, but that seems like I'd be banging a square peg in a round hole. What is the concept that I'm missing?