In a PowerShell script, I'm capturing the string output of an EXE file in a variable, then concatenating it with some other text to build an email body.
However, when I do this I find that the newlines in the output are reduced to spaces, making the total output unreadable.
# Works fine
.\other.exe
# Works fine
echo .\other.exe
# Works fine
$msg = other.exe
echo $msg
# Doesn't work -- newlines replaced with spaces
$msg = "Output of other.exe: " + (.\other.exe)
Why is this happening, and how can I fix it?