Write-Build

September 18, 2025 ยท View on GitHub

(print) Writes text using colors if they are supported.

Syntax

Write-Build [-Color] ConsoleColor [-Text] String

Description

This function is used in order to output colored text in a console or other
hosts with colors. Unlike Write-Host it is suitable for redirected output.

Write-Build is designed for tasks and build blocks, not script functions.

With PowerShell 7.2+ and $PSStyle.OutputRendering ANSI, Write-Build uses
ANSI escape sequences.

Parameters

-Color
    [System.ConsoleColor] value or its string representation.
    
    Values : Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White
    
    Required?                    true
    Position?                    0
-Text
    Text written using colors if they are supported.
    
    Required?                    true
    Position?                    1

Outputs

String