One of the great benefits of PowerShell is its pipeline mechanics that enable the output of one command to be passed to the next command in the pipeline. That output is not sent as basic text but rather the actual objects generated from a command are sent in the native object format to the next command and this is enabled for all commands.
If you open a PowerShell window and type the following commands the result is the same for both, Let we test this by below cmdlet.
PS C:\> Write-Host ("Hello " + $env:USERNAME)
PS C:\> Write-Output ("Hello " + $env:USERNAME)
If we looks the above script, it like they are the same but in reality they are working in very different ways. Let we discuss more to understand this.
From Example 1, we think that it seemed to achieve the same result for both Write-Output and Write-Host but we having difference among this two cmdlet. This can be demonstrated with a more detailed in this exampe. Write-Output sends the output to the pipeline. From there it can be piped to another cmdlet or assigned to a variable. Write-Host sends it directly to the console
$a = 'Testing Write-OutPut' | Write-Output
$b = 'Testing Write-Host' | Write-Host
From the above example, we can able see the Write-Output cmdlet has passed the value to the next process but Write-Host just directly write to the host and nothing has to send forward to the next cmdlet.
In simpler, if you possibly want to write data to the screen, but also want the data to be passed down the pipeline to further commands, then use Write-Output. Write-Host does not output data to PowerShell Object flow Engine but rather, as the name implies, writes directly to the host and sends nothing to the PowerShell engine to be forwarded to commands later in the pipeline.