List pending windows updates from command line

wmic qfe list gives me a list of Windows Updates installed on my system.

How do I get the list of the ones that are not installed (including whether or not they've been hidden)?

I want to use the list in another program I am developing, so I will need the output to be some sort of table in a file, such as csv or tab-delimited.


Not command-line, but thought this script from MSDN can help.

Source: WU Searcher WMI script from MSDN

Search WU for available updates and list them

Set updateSession = CreateObject("Microsoft.Update.Session")
updateSession.ClientApplicationID = "MSDN Sample Script"

Set updateSearcher = updateSession.CreateUpdateSearcher()

WScript.Echo "Searching for updates..." & vbCRLF

Set searchResult = _
updateSearcher.Search("IsInstalled=0 and Type='Software' and IsHidden=0")

WScript.Echo "List of applicable items on the machine:"

For I = 0 To searchResult.Updates.Count-1
    Set update = searchResult.Updates.Item(I)
    WScript.Echo I + 1 & "> " & update.Title
Next

If searchResult.Updates.Count = 0 Then
    WScript.Echo "There are no applicable updates."
    WScript.Quit
End If

The above code segment is to search WU for available updates, and list them without downloading. The remaining part of the script at MSDN is to download each of the available updates.

Copy the code to Notepad, and save it with .vbs extension.


Here is a quick powershell script to list available updates, if nothing is returnd, then no updates are available. There are two options for $r listed below, you can see how they differ.

$u = New-Object -ComObject Microsoft.Update.Session
$u.ClientApplicationID = 'MSDN Sample Script'
$s = $u.CreateUpdateSearcher()
#$r = $s.Search("IsInstalled=0 and Type='Software' and IsHidden=0")
$r = $s.Search('IsInstalled=0')
$r.updates|select -ExpandProperty Title