The middle one writes to the pipeline. Write-Host
and Out-Host
writes to the console. 'echo' is an alias for Write-Output
which writes to the pipeline as well. The best way to write to the console would be using the Write-Host
cmdlet.
When an object is written to the pipeline it can be consumed by other commands in the chain. For example:
"hello world" | Do-Something
but this won't work since Write-Host
writes to the console, not to the pipeline (Do-Something will not get the string):
Write-Host "hello world" | Do-Something