[bgreco.net]: PS C:\> Format-RainbowAdmit it. While the command line can be really useful, it can also be a bit boring. Here's a function to make your PowerShelling a bit more interesting. Because honestly, which of the following would you rather look at all day?


I know which I'd choose.
function Format-Rainbow([switch] $Random) {
$colors = 2, 3, 4, 6, 8, 10, 11, 12, 13, 14, 15
$i = 0
$input | Out-String -Stream | % {
$chars = $_.TrimEnd() -split ''
foreach($char in $chars) {
if($random) {
$color = Get-Random $colors
} else {
$color = $colors[$i % $colors.Length]
}
Write-Host -ForegroundColor $color $char -NoNewline
$i++
}
Write-Host
}
}