3

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.

Superbest
  • 1,980
  • 3
  • 26
  • 39
  • 1
    Possible duplicate of [command to list missing windows hotfixes](http://superuser.com/questions/1071969/command-to-list-missing-windows-hotfixes) – DavidPostill Aug 02 '16 at 12:38

4 Answers4

4

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.

w32sh
  • 11,524
  • 2
  • 39
  • 44
  • I've seen this as well, but since I don't know VB, I don't even know what this stuff does. As such it's not very useful to me. – Superbest Aug 02 '16 at 12:03
  • 1
    You don't have to know VB scripting to use this. Simply running the file should be enough. If I come across any other CLI solution like PowerShell, I'll update the post. – w32sh Aug 02 '16 at 12:08
  • 2
    This answer (from me) is a PowerShell solution [command to list missing windows hotfixes](https://superuser.com/a/1072130) – DavidPostill Aug 02 '16 at 12:40
4

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
Will
  • 41
  • 2
  • This is nice, but the problem is that it also lists old updates that you didn't want, and have *hidden*. – not2qubit Feb 22 '19 at 14:38
0

If you wish to do in one pipeline on remote PC:

Invoke-Command -ComputerName <ComputerName> -ScriptBlock {((New-Object -ComObject Microsoft.Update.Session).CreateUpdateSearcher()).Search('IsInstalled=0 and IsHidden=0').updates | Select-Object -Property Title,IsDownloaded,RebootRequired | ft -AutoSize}

ZygD
  • 2,459
  • 12
  • 26
  • 43
0

This is the snippet I use to patch Server Core versions. It shows the outstanding patches and start the install-process, too:

$criteria = "IsInstalled=0 and Type='Software'" 
$updateSession = new-object -com "Microsoft.Update.Session"
$updates = $updateSession.CreateupdateSearcher().Search($criteria).Updates
if ($updates.count -eq 0){'noting to update.'; break}
$updates | select Title
$downloader = $updateSession.CreateUpdateDownloader()          
$downloader.Updates = $updates
$null = $downloader.Download()
$installer = $updateSession.CreateUpdateInstaller()
$installer.Updates = $updates
$null = $installer.Install()
'done.'
# shutdown -r -t 0
Carsten
  • 291
  • 2
  • 7