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