Advertisement
metalx1000

Color Text Examples

Jun 2nd, 2015
810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. Text Color Examples
  3.  
  4. Example useage:
  5. PowerShell -ExecutionPolicy Bypass .\colors.ps1
  6. #>
  7. $colors = "Black","Blue","Cyan","DarkBlue","DarkCyan","DarkGray","DarkGreen","DarkMagenta","DarkRed","DarkYellow","Gray","Green","Magenta","Red","White","Yellow"
  8.  
  9. #forground colors
  10. foreach ($color in $colors){
  11.     write-host "This is $color text." -foregroundcolor $color
  12. }
  13.  
  14. foreach ($color in $colors){
  15.     write-host "This has a $color background." -backgroundcolor $color
  16. }
  17.  
  18. $text = "Many Colors Used Here..."
  19. $text = $text.ToCharArray()
  20.  
  21. foreach ($letter in $text){
  22.     $colors = $colors| Sort-Object {Get-Random}
  23.     write-host "$letter" -foregroundcolor $colors[0] -NoNewline
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement