The PowerShell code:
$string = @'
Line 1
Line 3
'@
$string
Outputs:
Line 1
Line 3
But I want it to output:
Line 1
Line 3
How can I achieve that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In ISE works fine and in
scriptworks too.I don’t remember where, but I read that is a bug in the console host code and empty lines are discarded when entered interactively for here-string.
At the moment I can’t test if in Powershell V.3.0 console bug is fixed.
Link to the issue: http://connect.microsoft.com/PowerShell/feedback/details/571644/a-here-string-cannot-contain-blank-line
Workaround: add a backticks `