How to echo with different colors in the Windows command line

前端 未结 23 1498
野性不改
野性不改 2020-11-22 08:55

I know that the color bf command sets the colors of the whole command line window but I wanted to to print one single line in a different color.

23条回答
  •  执念已碎
    2020-11-22 09:37

    Setting color to the log statements in powershell is not a big deal friend. you can use -ForegroundColor parameter.

    To write a confirmation message.

    Write-Host "Process executed Successfully...." -ForegroundColor Magenta
    

    To write an error message.

    Write-Host "Sorry an unexpected error occurred.." -ForegroundColor Red
    

    To write a progress message.

    Write-Host "Working under pocess..." -ForegroundColor Green
    

提交回复
热议问题