PowerShell Genie

Write-Host

Use Write-Host to display coloured messages in the console — status updates, warnings, and headings that stand out from normal output.

Command 4 min read PowerShell 7 on Windows

Documentation: Microsoft Learn — write-host

Syntax

1PS> Write-Host [[-Object] <Object>] [-ForegroundColor <ConsoleColor>] [-BackgroundColor <ConsoleColor>] [-NoNewline] [-Separator <Object>] [<CommonParameters>]

Try it

Windows PowerShell

PowerShell example · browser support is limited.

Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

Interactive simulation · fictional data

Examples

Write a green success message

1PS> Write-Host 'Deployment complete' -ForegroundColor Green
Show reference output

Illustrative output · values vary by environment

Deployment complete

Write on one line without a newline

1PS> Write-Host 'Processing...' -NoNewline -ForegroundColor Yellow Write-Host ' Done' -ForegroundColor Green
Show reference output

Illustrative output · values vary by environment

Processing... Done

Join several values with a separator

1PS> Write-Host 'Server','Database','Web' -Separator ' | ' -ForegroundColor Cyan
Show reference output

Illustrative output · values vary by environment

Server | Database | Web

Parameters

Parameter definitions:

  • -Object — The text or objects to display.
  • -ForegroundColor — Text colour: Black, DarkBlue, Green, Cyan, Red, Magenta, Yellow, White, and the Dark variants.
  • -BackgroundColor — Background colour behind the text.
  • -NoNewline — Writes without adding a newline, so the next output continues on the same line.
  • -Separator — Text placed between multiple objects instead of a space.

Microsoft Learn — write-host

Write-Host is for humans, never for data

Write-Host output cannot be captured, piped, or redirected to a file by the caller. If another script or person needs the value, use Write-Output instead. Reserve Write-Host for status messages a human reads while the script runs.

Since Windows PowerShell 5.1, Write-Host writes to the information stream, so it can be silenced with -InformationAction SilentlyContinue and captured with 6> file.txt. That makes it safer than it used to be, but it still does not go down the pipeline.

Colour is a readability tool, not decoration. Use one consistent scheme: green for success, yellow for warnings, red for errors, cyan for headings. Random colours on every line make output harder to scan, not easier.

Send data down the pipeline with Write-Output

Show a progress bar with Write-Progress

Updated 25 October 2026. Browser outputs are fictional; check the installed module help for your environment.

Recap

Write-Host Use Write-Host to display coloured messages in the console — status updates, warnings, and headings that stand out from normal output.

Next: Write Progress
Genie guideWrite-Host

Write-Host writes directly to the console with colour control: green for success, yellow for warnings, red for errors. Learn when to use it instead of Write-Output, and why it must never carry data. The console below is pre-loaded — run it, then change a value and run it again.