Write-Host
noun
say it: “RYT HOHST” /ˈraɪt ˈhoʊst/
A PowerShell command that writes words straight to the screen, in color if you like, for the person watching.
What does Write-Host do?
Write-Host writes words for the person watching the screen, such as a heading, in color with -ForegroundColor. The pipeline, a variable and a > file never get them, so keep results for Write-Output.
Write-Host 'Moving receipts to backup-drive' -ForegroundColor Cyan > moved.txt
# Moving receipts to backup-drive (on the screen, in cyan)
Get-Content moved.txt
# (nothing: the file is empty)
In a sentence
- “The mover prints its cyan heading with Write-Host, so the heading never ends up in moved.txt.”
- “Sam used Write-Host for the summary line meant only for his own eyes.”
Level: Apprentice · More PowerShell terms at this level
Updated