Recipes by topic

Installed Windows hotfixes

Win32_QuickFixEngineering lists the hotfixes known to the Windows servicing component, with their KB identifier.

Get-CimInstance -ClassName Win32_QuickFixEngineering |
    Select-Object -Property HotFixID, Description, InstalledBy, InstalledOn |
    Sort-Object -Property HotFixID

InstalledOn is a string whose format varies with the installation date (sometimes a hexadecimal FILETIME value): the script therefore sorts on HotFixID rather than on the date. The class does not list every update: those installed through other mechanisms can be missing.

Variant: remote

Checks for a KB on several servers: True if the hotfix is installed, False otherwise.

$kbNumber = 'KB5034441'
$cimSession = New-CimSession -ComputerName 'SERVER01', 'SERVER02'
try {
    $cimParameters = @{
        CimSession = $cimSession
        ClassName  = 'Win32_QuickFixEngineering'
        Filter     = "HotFixID = '{0}'" -f $kbNumber
    }
    $found = @(Get-CimInstance @cimParameters)
    foreach ($session in $cimSession) {
        $present = $found.PSComputerName -contains $session.ComputerName
        '{0}: {1}' -f $session.ComputerName, $present
    }
} finally {
    Remove-CimSession -CimSession $cimSession
}

Classes used

← All recipes