TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

PowerShell Write-Host

PowerShell Write-Host with What is PowerShell, History of PowerShell, Features of PowerShell, PowerShell vs CMD, PowerShell Scripting, PowerShell Versions, PowerShell Commands, PowerShell Looping, PowerShell Conditions, PowerShell Array, PowerShell Brackets etc.

<< Back to POWERSHELL

PowerShell Write-Host

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

Syntax

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

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

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

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

Examples

Example 1: Write output to the console by including a separator

PowerShell Write-Host

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

PowerShell Write-Host

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.






Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf