When scripting in PowerShell, it’s often useful to change the text and background colors to make certain outputs stand out. The Write-Host cmdlet in PowerShell allows for this customization. Here are some of the colors you can use:

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

You can set the text color using the ForegroundColor parameter and the background color using the BackgroundColor parameter.

Exemple

write-host "message" -BackgroundColor Yellow -ForegroundColor Black

This command will display the word “message” with a yellow background and black text.


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.