# Get-WindowsUpdateLog.ps1
# walk the WindowsUpdate.log to list the
# Security Updates that have been installed.

# [anything][PatchDate][anything][matchtext][PatchText]
$PATTERN  = "([^\n]+\}\t)"
$PATTERN += "(?<PatchDate>[0-9]{4}-[0-9]{2}-[0-9]{2})"
$PATTERN += "([^\n]+Windows successfully installed the following update:\s)"
$PATTERN += "(?<PatchText>[^\n]+)"

Function Get-WindowsUpdates($Server) {
 $WindowsUpdateLogPath = "\\" + $Server + "\Admin$\WindowsUpdate.log"
 $WindowsUpdateLog = Get-Content $WindowsUpdateLogPath
 $result = @()
 ForEach ($line in $WindowsUpdateLog) {
   if ($line.Contains("Windows successfully installed the following update:")) {
    if ( $line -match $PATTERN ) {
      $outObject= New-Object PSObject -Property @{
        updateDescription   = $matches.PatchText
        installDate         = $matches.PatchDate
      }
      $result += $outObject
    }
   }
 }
 $result
}

##################################################

if ($args.count -gt 0) { 
 $Server = $args
}
else {
 $Server = "localhost"
}

Get-WindowsUpdates $Server | FL