PowerShell Logo Small

Write-Host



This is the built-in help made by Microsoft for the command 'Write-Host', in PowerShell version 2 - as retrieved from Windows version 'Microsoft® Windows Vista™ Ultimate ' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Writes customized output to a host.

SYNTAX


Write-Host [[-Object] <Object>] [-BackgroundColor {Black | DarkBlue | DarkGreen | DarkCyan | DarkRed | DarkMagenta | DarkYellow | Gray | DarkGray
| Blue | Green | Cyan | Red | Magenta | Yellow | White}] [-ForegroundColor {Black | DarkBlue | DarkGreen | DarkCyan | DarkRed | DarkMagenta | Da
rkYellow | Gray | DarkGray | Blue | Green | Cyan | Red | Magenta | Yellow | White}] [-NoNewline] [-Separator <Object>] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Write-Host cmdlet customizes output. You can specify the color of text by using the ForegroundColor parameter, and you can specify the backgr
ound color by using the BackgroundColor parameter. The Separator parameter lets you specify a string to use to separate displayed objects. The pa
rticular result depends on the program that is hosting Windows PowerShell.



<

RELATED LINKS

Online version: http://go.microsoft.com/fwlink/?LinkID=113426
Write-Verbose
Write-Error
Write-Progress
Write-Debug
Write-Output
Write-Warning
Out-Host

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

C:\PS>write-host "no newline test " -nonewline

no newline test C:\PS>



Description
-----------
This command displays the input to the console, but because of the NoNewline parameter, the output is followed directly by the prompt.








-------------------------- EXAMPLE 2 --------------------------

C:\PS>write-host (2,4,6,8,10,12) -Separator ", +2= "

2, +2= 4, +2= 6, +2= 8, +2= 10, +2= 12



Description
-----------
This command displays the even numbers from 2 through 12. The Separator parameter is used to add the string , +2= (comma, space, +, 2, =, space).








-------------------------- EXAMPLE 3 --------------------------

C:\PS>write-host (2,4,6,8,10,12) -Separator ", -> " -foregroundcolor DarkGreen -backgroundcolor white



Description
-----------
This command displays the even numbers from 2 through 12. It uses the ForegroundColor parameter to output dark green text and the BackgroundColor
parameter to display a white background.








-------------------------- EXAMPLE 4 --------------------------

C:\PS>write-host "Red on white text." -ForegroundColor red -BackgroundColor white

Red on white text.



Description
-----------
This command displays the string "Red on white text." The text is red, as defined by the ForegroundColor parameter. The background is white, as d
efined by the BackgroundColor parameter.