Write a string to the display, optionally customizing the output. Output can be to any host but is typically the console screen.

      Write-Host [[-object] Object] [-noNewLine] [-separator Object]
             [-foregroundcolor ConsoleColor] [-backgroundColor ConsoleColor]

   -object Object
       Object to display, typically a string.
       Do not end with a newline character.
       String to output between objects displayed on the console.

   -foregroundcolor ConsoleColor
       The text color

   -backgroundcolor ConsoleColor
       Background color

       Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow,
       Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White

       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.

Write-host (and Write-Warning) write only to the host/screen. To also have the output passed to the success pipeline, use Write-Output.

Write-host by default adds a single space separator between items, to remove that you must specify an empty string '' as the separator


Display text in specific colours:

PS C:\> write-host "The quick brown fox jumped" -foregroundcolor DarkGreen -backgroundcolor white

PS C:\> Write-Host -ForeGroundColor Red "some text in red" -nonewline

Display several variables concatenated together with no separation character:

PS C:\> write-host $one $two -separator ''

“In our life there is a single color, as on an artist's palette, which provides the meaning of life and art. It is the color of love” ~ Marc Chagall

Related PowerShell Cmdlets:

Clear-Host - Clear the screen.
Out-Host - Send output to the host.
Write-Debug - Write a debug message to the host display.
Write-Output - Write an object to the pipeline.
Write-Warning - Write a warning message.

Copyright © SS64.com 1999-2019
Some rights reserved