Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Friday Fun – Get Happy Holiday

Posted on December 7, 2012

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
#http://thepowershellguy.com/blogs/posh/default.aspx

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

Clear-Host
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)
$i++
}

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
$rect.top = $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 = $r.next(16)

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

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

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

Share this:

  • Print (Opens in new window) Print

Like this:

Like Loading…

Related

3 thoughts on “Friday Fun – Get Happy Holiday”

  1. Jeffery Hicks says:
    December 7, 2012 at 1:46 pm

    Save the file as a .ps1 script and run it from the console. This will not work in the ISE.

  2. Pingback: Microsoft Most Valuable Professional (MVP) – Best Posts of the Week around Windows Server, Exchange, SystemCenter and more – #6 - Dell TechCenter - TechCenter - Dell Community
  3. Pingback: Microsoft Most Valuable Professional (MVP) – Best Posts of the Week around Windows Server, Exchange, SystemCenter and more – #6 - TechCenter - Blog - TechCenter – Dell Community

Comments are closed.

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2026 The Lonely Administrator | Powered by SuperbThemes!
%d