Simple Multi-Color Foreground Background Powershell Display Function

Apologies the blog’s been very quiet recently, been working on some major projects, and a couple of fairly major PowerShell tools. Still, I’ve found time for a favourite little function!

The one-line of code:

FUNCTION WrB { $i = 0; While ($i -lt $Args.Count){ Write-Host $Args[$i] -ForegroundColor $Args[$i+1] -BackgroundColor $Args[$i+2] -NoNewLine; $i+=3 } }

And an example of its use:

WrB "G" Blue White "o" Red White "o" Yellow White "g" Blue White "l" Green White "e" Red White

Image: Output - The Famous Google Sign in PowerShell!


Comments