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
Server:
.
foo
Do I really have to write to writewrite-output $("sfdghk:" + $a)
to get Server:Foo
Thanks -jt
In the case of the NoNewLine parameter, it is listed in the What's new in Windows PowerShell 5.0 article, and so that makes it easy to find. At other times, it means paying attention or actually searching by comparing commands from previous versions with commands from the latest version.
In a nutshell, Write-Host writes to the console itself. Think of it as a MsgBox in VBScript. Write-Output , on the other hand, writes to the pipeline, so the next command can accept it as its input. You are not required to use Write-Output in order to write objects, as Write-Output is implicitly called for you.
Found somewhere on the Internet:
Write-Output "Server: $($a)"
Works great in my code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With