CmdID / PowerShell / Cmdlets / Write
Write-Host
Writes customized output to a host. PowerShell reference
From the PowerShell reference 5 parameters
What it does
Writes customized output to a host. The Write-Host cmdlet's primary purpose is to produce for-(host)-display-only output, such as printing colored text like when prompting the user for input in conjunction with Read-Host. Write-Host uses the ToString() method to write the output. By contrast, to output data to the pipeline, use Write-Output or implicit 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 PowerShell. NOTE: Starting in Windows PowerShell 5.0, Write-Host is a wrapper for Write-Information. This allows you to use Write-Host to emit output to the information stream. This enables the capture or suppression of data written using Write-Host while preserving backwards compatibility. The $InformationPreference preference variable and InformationAction common parameter do not affect Write-Host messages. The exception to this rule is -InformationAction Ignore, which effectively suppresses Write-Host output. (see "Example 5")
Write-Host [[-Object] <Object>] [-NoNewline] [-Separator <Object>] [-ForegroundColor <ConsoleColor>] [-BackgroundColor <ConsoleColor>] [<CommonParameters>]
Write to the console without adding a new line
Write-Host "no newline test " -NoNewline
Write-Host "second string"IdentifyWrite to the console and include a separator
Write-Host (2,4,6,8,10,12) -Separator ", +2= "IdentifyWrite with different text and background colors
Write-Host (2,4,6,8,10,12) -Separator ", -> " -ForegroundColor DarkGreen -BackgroundColor WhiteIdentifyWrite with different text and background colors
Write-Host "Red on white text." -ForegroundColor red -BackgroundColor whiteIdentifySuppress output from Write-Host
# The following two statements can be used to effectively suppress output from Write-Host
Write-Host "I won't print" -InformationAction Ignore
Write-Host "I won't print" 6> $nullIdentifyParameters
-BackgroundColorSpecifies the background color. There is no default. The acceptable values for this parameter are:
- Black
- DarkBlue
- DarkGreen
- DarkCyan
- DarkRed
- DarkMagenta
- DarkYellow
- Gray
- DarkGray
- Blue
- Green
- Cyan
- Red
- Magenta
- Yellow
- White-ForegroundColorSpecifies the text color. There is no default. The acceptable values for this parameter are:
- Black
- DarkBlue
- DarkGreen
- DarkCyan
- DarkRed
- DarkMagenta
- DarkYellow
- Gray
- DarkGray
- Blue
- Green
- Cyan
- Red
- Magenta
- Yellow
- White-NoNewlineThe string representations of the input objects are concatenated to form the output. No spaces or newlines are inserted between the output strings. No newline is added after the last output string.-ObjectObjects to display in the host.-SeparatorSpecifies a separator string to insert between objects displayed by the host.