In a previous post I gave a DISM command to get a list of installed Windows Updates:
1 |
dism /online /Get-Packages /Format:Table |
While useful that command has no option of filtering results based on some criteria.
If you are on Windows 8 or above the Get-WindowsPackage
cmdlet can be of use:
1 |
Get-WindowsPackage -Online | ?{ $_.InstallTime -gt [datetime]::now.AddDays(-15) } |
This gets me all updates installed in the last 15 days.
Another alternative (on pre-Windows 8 machines) is good ol’ WMIC:
1 |
wmic qfe |
The above gives output similar to this:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Caption CSName Description FixComments HotFixID InstallDate Instal ledBy InstalledOn Name ServicePackInEffect Status http://support.microsoft.com/kb/2899189 GAIA Update KB2899189_Microsoft-Windows-CameraCodec-Package NT AUT HORITY\SYSTEM 3/22/2014 http://support.microsoft.com/?kbid=2843630 GAIA Update KB2843630 NT AUT HORITY\SYSTEM 3/22/2014 http://support.microsoft.com/?kbid=2868626 GAIA Security Update KB2868626 NT AUT HORITY\SYSTEM 3/22/2014 http://support.microsoft.com/?kbid=2883200 GAIA Update KB2883200 GAIA\A dministrator 9/30/2013 http://support.microsoft.com/?kbid=2887595 GAIA Update KB2887595 NT AUT HORITY\SYSTEM 3/22/2014 ... |
For more details more switches can be used:
1 |
wmic qfe list full |
Result is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
Caption=http://support.microsoft.com/kb/2899189 CSName=GAIA Description=Update FixComments= HotFixID=KB2899189_Microsoft-Windows-CameraCodec-Package InstallDate= InstalledBy=NT AUTHORITY\SYSTEM InstalledOn=3/22/2014 Name= ServicePackInEffect= Status= Caption=http://support.microsoft.com/?kbid=2843630 CSName=GAIA Description=Update FixComments= HotFixID=KB2843630 InstallDate= InstalledBy=NT AUTHORITY\SYSTEM InstalledOn=3/22/2014 Name= ServicePackInEffect= Status= Caption=http://support.microsoft.com/?kbid=2868626 CSName=GAIA Description=Security Update FixComments= HotFixID=KB2868626 InstallDate= InstalledBy=NT AUTHORITY\SYSTEM InstalledOn=3/22/2014 Name= ServicePackInEffect= Status= ... |
This output also gives an idea of the criteria available.
So how can I filter this output like I did with PowerShell? Easy – use WQL (WMIC Query Language). Inspired by a blog post I found (which I am sure I have referred to in the past too) either of the following will do the trick:
1 |
wmic qfe where "InstalledOn like '5/%/2015'" |
-or-
1 |
wmic qfe where (InstalledOn like "5/%/2015") |
And if you want to format the output with specific fields:
1 |
wmic qfe where "InstalledOn like '5/%/2015'" get Caption,Description,HotfixID,InstalledOn |
Which results in something along these lines:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
Caption Description HotFixID InstalledOn http://support.microsoft.com/?kbid=3013531 Update KB3013531 5/17/2015 http://support.microsoft.com/?kbid=3013538 Update KB3013538 5/17/2015 http://support.microsoft.com/?kbid=3015696 Update KB3015696 5/17/2015 http://support.microsoft.com/?kbid=3020370 Update KB3020370 5/17/2015 http://support.microsoft.com/?kbid=3021910 Update KB3021910 5/17/2015 http://support.microsoft.com/?kbid=3022345 Update KB3022345 5/16/2015 http://support.microsoft.com/?kbid=3023222 Security Update KB3023222 5/13/2015 http://support.microsoft.com/?kbid=3032663 Security Update KB3032663 5/13/2015 http://support.microsoft.com/?kbid=3033446 Update KB3033446 5/17/2015 http://support.microsoft.com/?kbid=3037924 Update KB3037924 5/17/2015 http://support.microsoft.com/?kbid=3038002 Update KB3038002 5/17/2015 http://support.microsoft.com/?kbid=3038562 Update KB3038562 5/17/2015 http://support.microsoft.com/?kbid=3038701 Hotfix KB3038701 5/17/2015 http://support.microsoft.com/?kbid=3043812 Update KB3043812 5/17/2015 |
This includes Updates, Hotfixes, and Security Updates. If you want to filter down further, that too is possible (just mentioning these as a reference to my future self). Do a specific match:
1 |
wmic qfe where "InstalledOn like '5/%/2015' and Description = 'Update'" get Caption,Description,HotfixID,InstalledOn |
Or a wildcard:
1 |
wmic qfe where "InstalledOn like '5/%/2015' and Description like '%Update'" get Caption,Description,HotfixID,InstalledOn |
Or a negation:
1 |
wmic qfe where "InstalledOn like '5/%/2015' and Description != 'Hotfix'" get Caption,Description,HotfixID,InstalledOn |
These two links (WQL and WHERE clauses) were of use in picking up the WQL syntax. They are not very explanatory but you get an idea by trial and error. Once I had picked up the syntax I came across this about_WQL page that’s part of the PowerShell documentation and explains WQL operators. Linking to it here as a reference to myself and others.
Unlike PowerShell I don’t know how to make WMIC use a greater than operator and simply specify the date. I tried something like this (updates installed after 12th May 2015):
1 |
wmic qfe where "InstalledOn > '5/12/2015' and Description != 'Hotfix'" get Caption,Description,HotfixID,InstalledOn |
But the results include some updates from 2013 & 2014 too. Not sure what’s wrong and I am not in the mood to troubleshoot at the moment. The like
operator does the trick well for me currently.