Skip to content

Instantly share code, notes, and snippets.

@jdhitsolutions
Created December 24, 2015 15:49
Show Gist options
  • Save jdhitsolutions/f40aadc0bbd73917c7b8 to your computer and use it in GitHub Desktop.
Save jdhitsolutions/f40aadc0bbd73917c7b8 to your computer and use it in GitHub Desktop.
Display a colorful and randomly selected Christmas message.
<#
Display a randomly selected holiday quote in a festive color scheme
you can find more Christmas quotes at
http://www.brainyquote.com/quotes/topics/topic_christmas.html
Learn more about PowerShell:
http://jdhitsolutions.com/blog/essential-powershell-resources/
#>
#The quote should include the author separated by " - ".
$texts = @(
"I will honor Christmas in my heart, and try to keep it all the year. - Charles Dickens",
"Merry Christmas to all and to all a good night! - Santa Claus",
"Christmas isn't a season. It's a feeling. - Edna Ferber",
"It is a fine seasoning for joy to think of those we love. - Moliere",
"Christmas, children, is not a date. It is a state of mind. - Mary Ellen Chase",
"Maybe Christmas, the Grinch thought, doesn't come from a store. - Dr. Seuss",
"Christmas waves a magic wand over this world, and behold, everything is softer and more beautiful. - Norman Vincent Peale"
)
#get random text
$text = Get-Random $texts
#split the text to an array on ' - '
$split = $text -split " - "
$quote = $split[0].Trim()
$author = $split[1].Trim()
#turn the quote into an array of characters
$arr = $quote.ToCharArray()
$arr | foreach -Begin {
cls
#define an array of colors
$colors = "Red","Green","White","Magenta"
#insert a few blank lines
write-host "`n"
#insert top border
write-host ("*"*$($quote.length+6))
#insert side border
write-host '* ' -NoNewline
} -process {
#write each character in a different holiday color
Write-Host $_ -ForegroundColor (Get-Random $colors) -NoNewline
} -end {
write-host ' *'
#insert side border
Write-Host "* " -NoNewline
#write the author
Write-Host "- $author *".padleft($quote.length+4)
#insert bottom border
write-Host ("*"*$($quote.length+6))
Write-Host "`n"
}
@jdhitsolutions
Copy link
Author

This script was first described at http://bit.ly/1PmKauh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment