Summary: Learn to use the Write-Host PowerShell cmdlet to create color output from commands.
Someone told me the Write-Host cmdlet could create color output. Can you give me some samples of acceptable syntax?
a. Write-Host -ForegroundColor 12 “hi”
b. Write-Host -ForegroundColor 12 “hi” -BackgroundColor white
c. Write-Host -ForegroundColor blue -BackgroundColor white
d. Write-Host -ForegroundColor 2 hi
e. Write-Host -backgroundcolor 2 hi
f. Write-Host -backgroundcolor (“{0:X}” -f 2) hi
for($i=0 ; $i -le 15 ; $i++) { write-host -foregroundcolor $i “hi” }
0 comments