Created
December 24, 2015 15:49
-
-
Save jdhitsolutions/f40aadc0bbd73917c7b8 to your computer and use it in GitHub Desktop.
Display a colorful and randomly selected Christmas message.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
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" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script was first described at http://bit.ly/1PmKauh.