PowerTip: Display Message in 16 Colors

Doctor Scripto

Dr Scripto

Summary: Use Windows PowerShell to display a message in 16 colors.

Hey, Scripting Guy! Question  How can I use Windows PowerShell to easily display a message in 16 different colors to start my presentation
           with something a little different?

Hey, Scripting Guy! Answer  Use the range operator to create 16 numbers. Pipe the numbers to the Foreach-Object cmdlet. In the
           script block, use Write-Host, and specify the foreground color as the number.
           Here is the command (using aliases for conciseness):

0..15 | %{write-host -f $_ 'hi'}

0 comments

Comments are closed.