Use PowerShell to Create a Holiday Snow Person

Use PowerShell to Create a Holiday Snow Person

  • Comments 6
  • Likes

Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell here-strings to create an ASCII holiday snow person.

Microsoft Scripting Guy, Ed Wilson, is here. The Scripting Wife and I returned from our European tour yesterday, just in time for the Windows PowerShell users group in Charlotte. Yesterday, we did a script share type of event where everyone brought a script to share with the other members of the group.

Note   By the way, the Scripting Guys holiday series this year is written by honorary Scripting Guy and Microsoft PowerShell MVP Sean Kearney. It begins on December 21, 2012, and is called “It’s a Wonderful Shell.” Here is a video teaser to help get you in the spirit of things.

While Teresa and I were in Warsaw, we had the opportunity to visit with Microsoft PowerShell MVP Bartek Bielawski. One evening, we went into the old town and took pictures. Here is a picture of an old castle in the square. It was awesome seeing the moving snowflakes on the side. Way cool stuff.

Old castle in Warsaw

Use Windows PowerShell here-strings to simplify strings

Well, anyway, I thought it was a good inspiration to create a silly sort of Windows PowerShell script. By using a here-string, it is really easy to do ASCII art in Windows PowerShell. All I need to do is to store the ASCII art into a here-string and store the result in a variable. Next, I simply display the contents of the variable.

A here-string is much more useful than simply creating snow persons. For example, if you have a complicated connection string that may contain special characters, a here-string is a perfect answer. If you have a string you will invoke to run a complicated switch-induced command line, then a here-string may be a good solution as well. Anyway, here is the New-SnowPerson.ps1 script.

$snowowerson = @"        

                         ________                        

   *                    [________]     .     *

*               .       |________| /       .          *

                        |        |/

             *           ========= 

    *                  ______________

  *            ||||||  /            \

               ||> || (    0   0     )          .

     .         ||-  | |      O      |

               ||||||  \   {---}   /    *

   *           \====/   [~~~~~~~~~]

                \\//  _/====||=====\_

                _||-'`/     ||      \`'-._       *

        *    .-` )|  ;      ||       ;    '.

            /    `--.|      ||       |      `\

           |         \      ||       |-,      \         .

*           \       .;      \/       ; |_,    |

             `'''||` ,\      0       /,    `.__/

                 ||.`  '.    0     .'  `.             *

      *          ||       ` ' ' `       \

                 ||                      ;

   .          *  ||                      |    .

                 ||                      |              *

       @         ||                      |   @

 .__.-""-.__.-"""||                      ;.-"""-.__.-""-.__.

                 ||                     /

                 ||'.                 .'

                 ||  '-._  _ _  _ _.-'

"@

 

Clear-Host

$snowowerson

 

When I run the script in the Windows PowerShell console, the following appears.

Join me tomorrow for more cool Windows PowerShell stuff.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Ha - that's the reason why we install hundreds of gigabytes of RAM into our servers - that santa is appearing within mili-seconds :-)

  • @Peter Forster there is something just fun about using Windows PowerShell to create ASCII art ... its like using a CNC machine to make ginger bread cookies.

  • Very useful! XD

  • Couldn't you have at least given him flashing eyes or something? This is taking me back to 1990.

    For inspiration I give exhibit A www.energizedtech.com/.../powershell-oh-christmas-tree-o.html

  • I'm loving it! Festive cheer to all. Happy Holidays!

  • Ed

    Ok.... I have to... I CAN'T resist!

    That is the "Coolest" post ever!  "Man" I can believe it!  It's "Snow" amazing!

    Putting the puns at bay and Happy Holidays buddy! :)

    Sean

    "Mr. Twinkly Lights" ;)