Finding Installed Updates (and searching for missing) (Part 1)

Windows can automatically determine the updates that may be missing on your system, provided you have an Internet connection. PowerShell can use the same system interfaces to query this information. The code below returns information about all updates installed on your system:

#requires -Version 2.0

$Session = New-Object -ComObject Microsoft.Update.Session
$Searcher = $Session.CreateUpdateSearcher()
$updates = $Searcher.Search("IsInstalled=1").Updates 

$updates |
  Select-Object Title, LastDeployment*, Description, SupportUrl, MsrcSeverity |
  Out-GridView

To see the updates you are actually missing, change “IsInstalled=1” to “IsInstalled=0”:

#requires -Version 2.0

$Session = New-Object -ComObject Microsoft.Update.Session
$Searcher = $Session.CreateUpdateSearcher()
$updates = $Searcher.Search("IsInstalled=0").Updates 

$updates |
  Select-Object Title, LastDeployment*, Description, SupportUrl, MsrcSeverity |
  Out-GridView

Twitter This Tip! ReTweet this Tip!

  • i receive next error:

    Excepción de HRESULT: 0x8024401F

    En línea: 5 Carácter: 1

    + $updates = $Searcher.Search("IsInstalled=0").Updates

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

       + CategoryInfo          : OperationStopped: (:) [], COMException

       + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException