Powershell to see what Updates have been installed

I was playing around in Powershell today and ran into this nice set of commands that will show you what Updates have been installed as known by the Windows Update Agent:

First create a variable and bind it to the "Microsoft.Update.Searcher" Com Object:

$wu = new-object -com "Microsoft.Update.Searcher"

A quick list of the members returns:

Name                                MemberType Definition
----                                ---------- ----------
BeginSearch                         Method     ISearchJob BeginSearch (string, IUnknown, Variant)
EndSearch                           Method     ISearchResult EndSearch (ISearchJob)
EscapeString                        Method     string EscapeString (string)
GetTotalHistoryCount                Method     int GetTotalHistoryCount ()
QueryHistory                        Method     IUpdateHistoryEntryCollection QueryHistory (int, ...
Search                              Method     ISearchResult Search (string)
CanAutomaticallyUpgradeService      Property   bool CanAutomaticallyUpgradeService () {get} {set}
ClientApplicationID                 Property   string ClientApplicationID () {get} {set}
IgnoreDownloadPriority              Property   bool IgnoreDownloadPriority () {get} {set}
IncludePotentiallySupersededUpdates Property   bool IncludePotentiallySupersededUpdates () {get}...
Online                              Property   bool Online () {get} {set}
ServerSelection                     Property   ServerSelection ServerSelection () {get} {set}
ServiceID                           Property   string ServiceID () {get} {set}

So it looks like I can do a QueryHistory to see what has been installed.  Before doing so I need to know how many updates have been installed.

$totalupdates = $wu.GetTotalHistoryCount()

Now I can run this command to see my update history:

$wu.QueryHistory(0,$totalupdates)

This will list all of the updates along with the following properties:

Name
----
Categories
ClientApplicationID
Date
Description
HResult
Operation
ResultCode
ServerSelection
ServiceID
SupportUrl
Title
UninstallationNotes
UninstallationSteps
UnmappedResultCode
UpdateIdentity