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”
$today=get-date
#Working out the number of days to go
$days = ($xmas.dayofyear – $today.dayofyear)
write-host “There are “$days“ days 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!
More likely to induce panic than cheer me up!!! 🙂
Have-HappyXmas !