I noticed in the Powershell forums somebody looking for a Script to show what date some Sql updates went in.
 
I don’t think this new one met the need but I started wondering If I could dump a little more than the installed programs.
 
Turns out the Registry keeps a lot of information on installed programs and updates, including the date and time it was installed.
 
So I expanded my original "LISTAPPS.PS1" script for dumping installed applications.    It wasn’t hard to add in additional lines to push out the "Version" and "Date"
 
But I stumbled across a few problems in those registry keys.
 
Some entries are created with NO useful information and thus no Date.  So when I started trying some Cool methods, they, errrr…. well… They freaked at NULL information.
 
So I had to get a LITTLE fancy into three spots, well fancy for a basic Scripter like myself.
 
I had to slip in an "IF ELSE" on the name, if it was a Null, well I didn’t really care about it.
 
But I also stumbled that some installed apps don’t stamp the DATE/TIME like they should.    So yet another "IF ELSE" to catch bad date info and output "UNKNOWN".  The nice thing in Powershell is I can switch a variable from any type on the fly. 
 
Second little problem (well not a problem, but something *I* wanted done, was I needed the DATE to show up as well, a DATE, readable instead of a cryptic "20090925".  We can all figure what that means but that defeats the purpose of making something like the registry readable to a user.
 
So I learned how to work the [DATETIME]::Parse method thanks to an excellent article on Powershell.com and played about for the first time since my days in "Waterloo Structured Basic" with Substrings.   
 
Now I’m certain there’s a really COOL and fancy way to do this, but the point of anything I do in Powershell is a) Be useful and b) Let a new person look at it and UNDERSTAND simply enough that THEY could take it over and get into it.
 
So the new script will do the same as the original but pump out "Install Dates" (if they’re available) as well as the applications and updates.
 
——————— LISTAPPS.PS1 ————– Just because we can do it ————————
 
#$list=get-childitem HKLM:SoftwareMicrosoftWindowsCurrentVersionUninstall
$list=get-childitem REGISTRY::HKEY-LOCAL-MACHINESoftwareMicrosoftWindowsCurrentVersionUninstall
Foreach ($App in $list)
{
    $Displayname=(get-itemproperty registry::$App).DisplayName;
    $DisplayVersion=(get-itemproperty registry::$App).DisplayVersion;
    $InstallDate=(get-itemproperty registry::$App).InstallDate;
    If ($Displayname -ne $NULL)
    {
        If ($InstallDate -ne $NULL)
        {
            $year=$InstallDate.substring(0,4)
            $month=$InstallDate.substring(4,2)
            $day=$InstallDate.substring(6,2)
            $DATEINSTALLED=[DateTime]::Parse($month+’.’+$day+’.’+$year)
        }
       
        Else
        {
       
        $DATEINSTALLED=’Unknown’
       
        }
    Write-Host "Application", $Displayname, "Version", $DisplayVersion, "Date Installed", $DATEINSTALLED
    }
    
}
——————————- LISTAPPS.PS1 —— Game over man ————————–
 
Enjoy and modify it as you need, or use it just to learn how you can work and manipulate information in Powershell.
 
No script has to be amazing, it just has to be useful to you 🙂
 
Cheers
 
Sean
The Energized Tech