Page 1 of 1

Reporting of the latest KB

Published: June 11, 2024 - 12:19
by Gaetan
Good morning,

Here is a query that retrieves the last KB installed on the machine, as well as its date.

Option to filter by OR or not by removing the last line.

You need to have WUA enabled on WAPT.

Code: Select all

WITH LastKBInstall AS (
    SELECT
        hw.host_id AS host_uuid,
        hw.update_id AS kb_number,
        hw.install_date,
        ROW_NUMBER() OVER (PARTITION BY hw.host_id ORDER BY hw.install_date DESC) AS rn
    FROM
        hostwsus hw
)
SELECT
    lki.host_uuid,
    h.computer_name,
    lki.kb_number,
    lki.install_date
FROM
    LastKBInstall lki
JOIN
    hosts h ON lki.host_uuid = h.uuid
WHERE
    lki.rn = 1
    AND h.computer_ad_ou LIKE '%%OU%%';