Home > Windows 8 > Seasons Greetings with PowerShell

Seasons Greetings with PowerShell

So it’s got to the time of year again where folks are already starting to wrap presents and put up decorations. So far in our house, only my eldest daughter has bought AND wrapped all her gifts – good for her, whereas mum and dad still have some work to do…

Anyway, to cheer myself up, I have dusted off the annual PowerShell script from the loft, and am putting the tinsel around it out for all to wonder at.

Try this in PowerShell to amuse yourself in the countdown to the big day.

# Function to calculate the number of days until Christmas
# Call by typing ‘Days-Left’
Function Days-Left
$xmas=[system.datetime]”25 December 2013”

#Working out the number of days to go
$days = ($xmas.dayofyear – $today.dayofyear)

write-host “There are$daysdays until Christmas!”

Alternatively, try this one-liner as well.

Write-Host (“There are “ +(([system.datetime]”25 December 2013”).DayOfYear – (Get-Date).DayOfYear) + ” days until Christmas!”)

Merry-Christmas folks!

Categories: Windows 8
  1. mattypenny
    December 7, 2012 at 11:05 am

    More likely to induce panic than cheer me up!!! 🙂

    Have-HappyXmas !

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: