Commands / Text and objects

Write-Output

Print a message (Write-Output vs Write-Host)

beginner Text and objects Aliases echowrite

Write-Output
 Write-Output 'Backup finished'
Works on
WindowsLinuxmacOS
PowerShell
5.1 and later
Reference
Microsoft Learn: Write-Output

Both commands show text, but they are not the same:

Write-Output Write-Host
Goes down the pipeline Yes No
Can be saved with > or Out-File Yes No
Colors No -ForegroundColor
Use it for Results Messages for the person watching

In a script, a bare value on its own line is the same as Write-Output. So 'Done' prints "Done."

For progress or warnings, there are also Write-Verbose, Write-Warning, and Write-Progress, which people can turn off or redirect.

Try this

Write-Host 'Checking disks...' -ForegroundColor Cyan
Write-Output 'C: ok' | Out-File -FilePath .\report.txt
Get-Content -Path .\report.txt

Only "C: ok" ends up in the file.

Coming from another shell

ShellWhat you might type
bash / zshecho 'Backup finished'
cmd.exeecho Backup finished

More in From bash and From cmd.

Related commands