Simpsons Movie Countdown with PowerShell (Repost)

Here is a repost from my old blog. This was originally posted on July 27th, 2007. Sorry all pictures are gone.

Yeah, I’m trying new things with PowerShell. Someone challenged me to see if I could come up with how long til the movie. Well that was pretty easy. I did:

New-TimeSpan (Get-Date) “7/27/2007 12:01:00″

Days : 1 Hours : 20 Minutes : 31 Seconds : 53 Milliseconds : 146 Ticks : 1603131460301 TotalDays : 1.85547622720023 TotalHours : 44.5314294528056 TotalMinutes : 2671.88576716833 TotalSeconds : 160313.1460301 TotalMilliseconds : 160313146.0301

I turned around and used the PowerGadgets and borrowed some code from Richard Siddaway to come up with this:

param([datetime]$end = “Friday, July 27, 2007 12:01:00 AM”)

$t = $end - (get-date)

if ($t.Seconds -lt 10) {$s = “0″ + ([System.Math]::Truncate($t.Seconds)).ToString() }

else { $s = ([System.Math]::Truncate($t.Seconds)).ToString() }

$d = ([System.Math]::Truncate($t.days)).ToString() $h = ([System.Math]::Truncate($t.Hours)).ToString() $m = ([System.Math]::Truncate($t.Minutes)).ToString()

$d + ” Day ” + $h + ” hours ” + $m + ” minutes ” + $s + ” seconds “

I then outputed these results to a PowerGadget:

.\simpsons-countdown.ps1|out-gauge -Type Digital -refresh 00:00:01 -ToolTip “Time til The Simpsons Movie” -Appearance_color Yellow

And this is what I got:

Pretty cool huh? I may have to purchase the PowerGadgets when my 30 day trial is over. I could get some use out of them.

comments powered by Disqus