I want to collect all output from my script in a log file and must use write-output instaed of write-host.
Write-Output \"Server:\" $a looks like
9 hours ... I start an answer.
In Powershell everything you manipulate is an object.
so "Server:" is an object, $a is an object
PS> "server :".gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
Write-output is a CmdLet that put object in a kind of list (a pipe) to be used by other CmdLets or scripts. So there is not a really a newline between "Server:" and "foo". It's the way the console show you a list (an array) of objects. As you can see here under :
PS> $a = "foo"
PS> (Write-Output "Server :" $a).gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
Clearly it's an abstract here, but I hope it can make you understand.