C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
PowerShell Write-HostThe PowerShell Write-Host cmdlet is used to write the customized output to a host. We can specify the text color by using the -foreground parameter, and by using the -background parameter, we can specify the background color. SyntaxWrite-Host [[-Object] <Object>] [-NoNewline] [-Separator <Object>] [-ForegroundColor {Black | DarkBlue | DarkGreen | DarkCyan | DarkRed | DarkMagenta | DarkYellow | Gray | DarkGray | Blue | Green | Cyan | Red | Magenta | Yellow | White}] [-BackgroundColor {Black | DarkBlue | DarkGreen | DarkCyan | DarkRed | DarkMagenta | DarkYellow | Gray | DarkGray | Blue | Green | Cyan | Red | Magenta | Yellow | White}] [<CommonParameters>] Parameters-Object The -Object parameter is used to display the objects in the host. -NoNewline The -NoNewline parameter specifies that no spaces or newlines are inserted between the output strings, and there is no newline which is added after the last output string. -Separator The -Separator parameter is used to specify a separator string which is inserted between the objects displayed by the host. -ForegroundColor The -ForegroundColor parameter is used to specify the color of the text. In this parameter, there is no default value exists. Following are the acceptable values for this parameter:
-BackgroundColor The -BackgroundColor parameter is used to specify the color of the background. There is no default value exists in this parameter. Following are the acceptable values for this parameter:
ExamplesExample 1: Write output to the console by including a separator The cmdlet in this example is used to display the numbers from two through twelve. The -Separator parameter is used to multiply the string. Example 2: Write with different text and background color The cmdlet in this example displays the odd numbers from one through 17. It uses the -ForegroundColor parameter to output 'Red' text and the -BackgroundColor parameter to display a 'black' background.
Next TopicPowerShell Get-Command
|