Friday Fun – Get Happy Holiday

Today’s Friday Fun is my version of a script originally posted a few years ago by The PowerShell Guy. I’ll list the code but you really need to run it to enjoy it.

#requires -version 2.0

#This must be run from the PowerShell console. NOT in the ISE.

#this is based on a script originally posted by The PowerShell Guy

$Greeting = "$([char]14) **Happy Holidays** $([char]14)"

Write-host "`n"
$Peek = " ^ "
$tree = "/|\"
$i = 20
$pos = $host.ui.rawui.CursorPosition
#adjust to center the display
$offset = ($host.ui.rawui.WindowSize.Width - 72)/2

write-host -fore 'red' ($peek.PadLeft($i-1).PadRight(36) * 2)
write-host -fore 'green' ($tree.PadLeft($i-1).PadRight(36) * 2)

1..16 | Foreach {
    #build out the tree
    $tree = $tree -replace "/(.*)\\",'//$1\'
    write-host -fore 'green' ($tree.PadLeft($i).PadRight(36) * 2)

write-host -fore 'green' ("|||".PadLeft(19).PadRight(36) *2 )
write-host -fore 'green' ("|||".PadLeft(19).PadRight(36) *2)

$rect = New-Object System.Management.Automation.Host.Rectangle
$ = $pos.y
$rect.Right = 70
$rect.Bottom = $pos.y + 19
$buffer = $host.ui.rawui.getbuffercontents($rect)
#random number object
$R = new-object system.random
$ball = new-object System.Management.Automation.Host.BufferCell
$ball.backgroundColor = $host.ui.rawui.BackgroundColor

1..150 | ForEach {
    sleep -Milliseconds 100
    #get a random position
    $rx = $r.Next(19)
    $ry = $r.Next(70)

    #define a collection of figures to be used as ornaments
    $ornaments = '@','*','#',":"
    #get a random ornament
    $ball.Character = Get-Random $ornaments
    $ball.ForegroundColor = $

    if ($buffer[$rx,$ry].Character -eq '/') {$buffer[$rx,$ry] = $ball}
    if ($buffer[$rx,$ry].Character -eq '\') {$buffer[$rx,$ry] = $ball}

#write the greeting centered
$pos.y = $pos.y + 22
$pos.x = 36 - (($Greeting.Length)/2)

Write-Host $Greeting -Fore 'red'

This is probably the epitome of PowerShell fun: not practical in any way but still done with PowerShell. Enjoy.

Download Get-HappyHoliday

Post to Twitter Post to Plurk Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to FriendFeed Post to Google Buzz Post to Post to Reddit Post to Slashdot Post to StumbleUpon Post to Technorati

About the Author Announcer

This is the official account for and sponsor announcements.