PowerShell Logo Small

Write-Host



This is the built-in help made by Microsoft for the command 'Write-Host', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' 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 | DarkYellow | Gray | DarkGray | Blue | Green | Cyan |
Red | Magenta | Yellow | White}] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String>]] [-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 background color by using the
BackgroundColor parameter. The Separator parameter lets you specify a string to use to separate displayed objects. The particular result depends on the program that is
hosting Windows PowerShell.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=294029
Clear-Host
Out-Host
Write-Debug
Write-Error
Write-Output
Write-Progress
Write-Verbose
Write-Warning

REMARKS

<

Examples


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

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



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










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

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



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 --------------------------

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



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 --------------------------

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



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