Important difference:
Write-output writes an object to the pipeline, so the next command can accept it as it's input.
While Write-host just write directly to the console.
In your example
Write-Output will write the object to the pipeline, and Out-Default (Hidden at the end of the pipeline) will display the object values in either a table or a list.
Write-Host writes directly to the console instead of using the default cmdlet Out-default in the end of the pipeline. In other words, Write-Host does not write anything to the pipeline, only displays what he sees to the console..
This is why you can add parameters like -foregroundcolor to the Write-Host cmdlet, but not to the Write-output cmdlet.
Write-Host is useful when debugging and you need to display text in diffrent colors.
You can simply test this with
Write-Output "Hello World" | Get-Member
We can se that this is a System.String Object.
If we run:
Write-Host "Hello World" | Get-Member
We get an error:
gm : You must specify an object for the Get-Member cmdlet ...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…