SCCM SQL Query to get Last State computers in Software Update deployment

Boopathi S 3,806 Reputation points
2021-10-21T16:08:47.47+00:00

Hello,

Computers list to be extracted for troubleshooting purpose for the below each Last state in the default report
Software Updates - C Deployment States > States 1 - Enforcement states for a deployment

Enforcement state unknown
Installing update(s)
Downloading update(s)
Downloaded update(s)
Pending system restart
Failed to install update(s)

142554-capture.jpg

We have deployment for PrePilot, Pilot, Production. I need to select each of the above Last State for each deployment. Then export the computers and collate in a excel file to start work on troubleshooting

Is there any SCCM SQL query to run and get the list of computers in all the last state for each deployment ?
Please share the query if it exits.

Microsoft Security | Intune | Configuration Manager | Updates
0 comments No comments
{count} votes

Accepted answer
  1. AllenLiu-MSFT 49,311 Reputation points Microsoft External Staff
    2021-10-22T06:33:48.953+00:00

    Hi, @Boopathi S
    Thank you for posting in Microsoft Q&A forum.

    Please try below query, replace the AssignmentID with your Deployment ID.

    select  
    sn.StateName as LastEnforcementState,  
    vrs.name0 as ComputerName,  
    a.AssignmentName as DeploymentName,  
    assc.StateTime ,  
    a.CollectionName  
    from v_CIAssignment a  
    join v_AssignmentState_Combined assc on a.AssignmentID=assc.AssignmentID  
    join v_StateNames sn on assc.StateType = sn.TopicType and sn.StateID=isnull(assc.StateID,0)  
    join v_R_System vrs on vrs.ResourceID=assc.ResourceID  
    where a.AssignmentID='xxxxxxxx'  
    order by LastEnforcementState  
    

    142863-1.jpg


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



0 additional answers

Sort by: Most helpful

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.