Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Use PowerShell to Create Color Output from Commands

$
0
0

Summary: Learn to use the Write-Host PowerShell cmdlet to create color output from commands.

Hey, Scripting Guy! Question Someone told me the Write-Host cmdlet could create color output. Can you give me some samples of acceptable syntax?

Hey, Scripting Guy! Answer

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" }


Viewing all articles
Browse latest Browse all 3333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>