Archive

Posts Tagged ‘cmdlet’

Prevent write-output to perform linebreak

November 20, 2014 Leave a comment

Sometimes you want to output some text and append an variable. Problem is that write-output usually performs a linebrak when appending.


$text = "some text."
Write-Output "this is " $text

Output will be:
this is
some text.

There are two ways you can solve this. One is to append the text to the variable before doing write-output. Second is to put the variable inside the quotation marks.


#Example 1
$text = "some text."
$textmessage = "This is " + $text
Write-Output $textmessage

#Example 2
$text = "some text."
Write-Output "this is $($text)"

%d bloggers like this: