My problem is related to PowerShell 4.0 (Win7).
The goal is to get a chosen multiline string out of a textfile together with another prepared text.
I'm using the following code:
$nl = [System.Environment]::NewLine
[string]$text1 = 'Hello World' + $nl
$b = (Get-Content textfile.txt | Out-GridView -OutputMode Multiple)
Content of textfile.txt:
tester 1
tester 2
tester 3
I choose tester 1 and tester 2 from GridView and click OK
An output of $b gives me the following (expected) result in 2 separate lines:
$b
tester 1
tester 2
So far, so good
Now I'm putting the strings together with:
$test = $text1 + $b
An output of $test gives me the following (unexpected) result:
$test
Hello World
tester 1 tester 2
Question: Why is the output of $test not in 2 separate lines as was the output of $b ??
I wanted it to be:
Hello World
tester 1
tester 2