List Installed Security Patches with PowerShell

If you want to know which security patches were installed on a Microsoft Windows system within a specific time period, e.g., the last month or the last 3 months, you can use a Get-CimInstance command in a PowerShell window. E.g.:

PS C:\Users\Lila> Get-CimInstance -Class win32_quickfixengineering | Where-Object { $_.InstalledOn -gt (Get-Date).AddMonths(-1) }

Source        Description      HotFixID      InstalledBy          InstalledOn
------        -----------      --------      -----------          -----------
              Security Update  KB4025376     NT AUTHORITY\SYSTEM  7/12/2017 12:00:00 AM
              Security Update  KB4025342     NT AUTHORITY\SYSTEM  7/12/2017 12:00:00 AM


PS C:\Users\Lila> Get-CimInstance -Class win32_quickfixengineering | Where-Object { $_.InstalledOn -gt (Get-Date).AddMonths(-3) }

Source        Description      HotFixID      InstalledBy          InstalledOn
------        -----------      --------      -----------          -----------
              Security Update  KB4020821     NT AUTHORITY\SYSTEM  6/17/2017 12:00:00 AM
              Update           KB4021572     NT AUTHORITY\SYSTEM  6/17/2017 12:00:00 AM
              Update           KB4022405     NT AUTHORITY\SYSTEM  6/17/2017 12:00:00 AM
              Security Update  KB4025376     NT AUTHORITY\SYSTEM  7/12/2017 12:00:00 AM
              Security Update  KB4025342     NT AUTHORITY\SYSTEM  7/12/2017 12:00:00 AM


PS C:\Users\Lila>

The number of months you want to look back is specified by putting a negative number in the parentheses after AddMonths. E.g., -3 to view the patches installed in the last 3 months. Alternatively, you can specify the number of days, instead of months, by substituting AddDays for AddMonths. E.g., to view security patches installed in the last 30 days:

PS C:\Users\Lila> Get-CimInstance -Class win32_quickfixengineering | Where-Object { $_.InstalledOn -gt (Get-Date).AddDays(-30) }

Source        Description      HotFixID      InstalledBy          InstalledOn
------        -----------      --------      -----------          -----------
              Security Update  KB4025376     NT AUTHORITY\SYSTEM  7/12/2017 12:00:00 AM
              Security Update  KB4025342     NT AUTHORITY\SYSTEM  7/12/2017 12:00:00 AM


PS C:\Users\Lila>

Alternatively, you can use the Get-Hotfix cmdlet.

PS C:\Users\Lila> Get-Hotfix

Source        Description      HotFixID      InstalledBy          InstalledOn
------        -----------      --------      -----------          -----------
VALERIAN      Security Update  KB4020821     NT AUTHORITY\SYSTEM  6/17/2017 12:00:00 AM
VALERIAN      Update           KB4021572     NT AUTHORITY\SYSTEM  6/17/2017 12:00:00 AM
VALERIAN      Update           KB4022405     NT AUTHORITY\SYSTEM  6/17/2017 12:00:00 AM
VALERIAN      Security Update  KB4025376     NT AUTHORITY\SYSTEM  7/12/2017 12:00:00 AM
VALERIAN      Security Update  KB4025342     NT AUTHORITY\SYSTEM  7/12/2017 12:00:00 AM


PS C:\Users\Lila>

References:

  1. PowerTip: Get a list of security patches installed in the last 90 days
    By: The Scripting Guys
    Date: February 3, 2017
    Hey, Scripting Guy! Blog
  2. Use PowerShell to Easily Find Information About Hotfixes
    By: The Scripting Guys
    Date: August 22, 2011
    Hey, Scripting Guy! Blog