SCCM SQL Query :Patch compliance progression report


select
      CS.Name0,
      CS.UserName0,
case
when (sum(case when UCS.status=2 then 1 else 0 end))>0 then ('Needs '+(cast(sum(case when UCS.status=2 then 1 else 0 end)as varchar(10))+ ' Patches'))
else 'Good Client'
end as 'Status',
      ws.lasthwscan as 'Last HW scan',
      FCM.collectionID--,
from
      v_UpdateComplianceStatus UCS
left outer join dbo.v_GS_COMPUTER_SYSTEM  CS on CS.ResourceID = UCS.ResourceID
join v_CICategories_All catall2 on catall2.CI_ID=UCS.CI_ID
join v_CategoryInfo catinfo2 on catall2.CategoryInstance_UniqueID = catinfo2.CategoryInstance_UniqueID and catinfo2.CategoryTypeName='UpdateClassification'
left join v_gs_workstation_status ws on ws.resourceid=CS.resourceid
left join v_fullcollectionmembership FCM on FCM.resourceid=CS.resourceid
Where
      UCS.Status = '2'
and FCM.collectionid = 'SMS00001'
Group by
      CS.Name0,
      CS.UserName0,
      ws.lasthwscan,
      FCM.collectionID
Order by
      CS.Name0,
      CS.UserName0,
      ws.lasthwscan,
      FCM.collectionID



output ::

Name0UserName0StatusLast HW scancollectionID
MACHINE1CONTOSO\USER11Needs 43 Patches7/1/2014 9:47SMS00001
MACHINE2CONTOSO\USER2Needs 43 Patches6/30/2014 14:16SMS00001
MACHINE3CONTOSO\USER3Needs 61 Patches7/1/2014 12:34SMS00001
MACHINE4NULLNeeds 23 Patches7/2/2014 12:27SMS00001
MACHINE5CONTOSO\USER5Needs 36 Patches7/1/2014 12:08SMS00001
MACHINE6NULLNeeds 51 Patches6/5/2014 20:05SMS00001
MACHINE7CONTOSO\USER8Needs 30 Patches7/2/2014 12:54SMS00001
MACHINE8NULLNeeds 32 Patches6/27/2014 8:28SMS00001
MACHINE9CONTOSO\USER9Needs 43 Patches6/19/2014 9:15SMS00001
MACHINE10CONTOSO\USER12Needs 10 Patches6/30/2014 9:50SMS00001

Comments

Popular posts from this blog