Managing and deploying updates via Configuration Manager
Use the software updates status views and state views that expose deployment assignment and enforcement information, then filter by the deployment (AssignmentID) and map the state IDs to the console buckets (In Progress, Error, Unknown).
A typical pattern is:
-- Replace @AssignmentID with the deployment ID of the Software Update Group
DECLARE @AssignmentID INT = 12345678; -- your deployment ID
SELECT
rs.Name0 AS DeviceName,
uas.AssignmentID,
uas.LastEnforcementMessageID,
sn.StateName AS LastEnforcementState, -- text, e.g. "Failed to install update(s)"
uas.LastEnforcementMessageTime,
uas.LastEnforcementErrorCode,
CASE sn.StateName
WHEN 'Succeeded' THEN 'Compliant'
WHEN 'Failed to install update(s)' THEN 'Error'
WHEN 'Waiting for another installation to complete'
THEN 'In Progress'
-- add other state name → bucket mappings as needed
ELSE 'Unknown'
END AS DeploymentStatusBucket
FROM v_UpdateAssignmentStatus AS uas
JOIN v_R_System AS rs
ON uas.ResourceID = rs.ResourceID
LEFT JOIN v_StateNames AS sn
ON sn.TopicType = 301 -- enforcement state messages
AND sn.StateID = uas.LastEnforcementMessageID
WHERE uas.AssignmentID = @AssignmentID;
Key points from the views used:
-
v_UpdateAssignmentStatus(orv_UpdateAssignmentStatus_Live) lists, per deployment and device:-
AssignmentID(deployment ID) -
ResourceID -
LastEnforcementMessageID -
LastEnforcementMessageTime -
LastEnforcementErrorCode
-
-
v_StateNamesprovides the human‑readable state name for a givenStateIDandTopicType.- For enforcement state,
TopicType = 301when usingLastEnforcementMessageIDfromv_UpdateAssignmentStatus.
- For enforcement state,
-
v_R_Systemgives the device name (Name0).
To reproduce the console’s In Progress / Error / Unknown counts, adjust the CASE expression so that each StateName (from v_StateNames) is mapped into the desired bucket according to the state definitions used in the environment.
For per‑update enforcement/compliance (rather than per‑deployment), use v_UpdateComplianceStatus joined to v_UpdateInfo, v_R_System, and v_StateNames on CI_ID, ResourceID, and LastEnforcementMessageID as shown in the sample queries.
References: