Für das schnelle kopieren, hier noch der vollständige Code für’s eigene Cmdlet.
Ich habe diesen soweit ergänzt, dass alle möglichen Farben unterstützt werden.
function advancedEcho {
param (
[Parameter(Mandatory=$true)] [string]$Text,
[alias("Sleep")][int]$Wait = 0,
[ValidateSet("Black","DarkBlue","DarkGreen","DarkCyan","DarkRed","DarkMagenta","DarkYellow","Gray","DarkGray","Blue","Green","Cyan","Red","Magenta","Yellow","White","None")] $TextColor = "None"
)
if ($TextColor -ne "None") {
$lastColor = [console]::ForegroundColor
[console]::ForegroundColor = $TextColor
}
echo "$Text"
sleep $Wait
if ($TextColor -ne "None") {
[console]::ForegroundColor = $lastColor
}
}