Skip to content

Instantly share code, notes, and snippets.

@sayedihashimi
Last active May 29, 2021 17:07
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sayedihashimi/8637262 to your computer and use it in GitHub Desktop.
Save sayedihashimi/8637262 to your computer and use it in GitHub Desktop.
PowerShell loop through console colors to display different results for foreground color & background color
[enum]::getvalues([type]'ConsoleColor') | ForEach-Object{
$curForeground = $_
[enum]::getvalues([type]'ConsoleColor') | ForEach-Object{
$curBackground = $_
$msgStart= "Foreground={0}, Background={1}" -f $curForeground,$curBackground
$msgStart += (New-Object string -ArgumentList @(' ',(50-$msgStart.Length)))
$msgStart | Write-Host -NoNewline
'Lorem ipsum dolor sit amet, consectet' | Write-Host -ForegroundColor $curForeground -BackgroundColor $curBackground
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment