WSUS SQL Queryt to get update stats

Qais Aqel 1 Reputation point
2021-09-05T12:27:39.917+00:00

Hello
I need to write SQL Queryt to get missing needed security updates from WSUS for all my domain server’s and workstations.

Can anyone help me ?

Thanks in advance

Windows for business Windows Server User experience Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,916 Reputation points
    2021-09-06T10:29:54.267+00:00

    Hello,

    here is the most common query used:

    SELECT left(tbComputerTarget.FullDomainName,30) as [Machine Name]
    ,count(tbComputerTarget.FullDomainName) as [# of Missing patches]
    ,tbComputerTarget.LastSyncTime as [Last Sync Time]
    FROM tbUpdateStatusPerComputer INNER JOIN tbComputerTarget ON tbUpdateStatusPerComputer.TargetID =
    tbComputerTarget.TargetID
    WHERE (NOT (tbUpdateStatusPerComputer.SummarizationState IN (’1′, ’4′))) AND
    tbUpdateStatusPerComputer.LocalUpdateID IN (SELECT LocalUpdateID FROM dbo.tbUpdate WHERE UpdateID IN
    (SELECT UpdateID FROM PUBLIC_VIEWS.vUpdateApproval WHERE Action=’Install’))
    GROUP BY tbComputerTarget.FullDomainName, tbComputerTarget.LastSyncTime
    ORDER BY COUNT(*) DESC

    1 = Not Installed
    2 = Needed
    3 = Downloaded
    4 = Installed
    5 = Failed

    I hope this will help you further!

    Regards,
    ALPD

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.