Home > Uncategorized > Simpsons Movie Countdown with PowerShell (Repost)

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.

Advertisements
  1. Tazalicious
    August 13, 2008 at 5:34 pm

    Thanks for the repost; fond memories of the midnight showing billow…

  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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: