PowerShell script to check when the computer was last patched (Using Windows Update Agent API)
Here is a small PS script to check when the target computer was last patched and what patch was installed.
$objSession = New-Object -com "Microsoft.Update.Session"
$objSearcher= $objSession.CreateUpdateSearcher()
$colHistory = $objSearcher.QueryHistory(1, 1)
Foreach($objEntry in $colHistory)
{
Write-host $objEntry.Title
Write-host $objEntry.Date
}
Unfortunately this doesn’t work on remote computer. (It can work on remote computer if using VBS). I am trying to figure out a way to use .NET or remote registry to do the same for remote computer without success so far.