Help Creating SCCM Custom Compliance Query

We can't used DCM for system compliance reports so I created the SQL query listed below which will be used as a system compliance report to run against the SCCM database.   The problem is that if the software is not on the the system altogether my query filters it out in the where statement.  I want the query to return if the software is on the system and if it's the correct version or not.  An example of the desired report is listed at the bottom of this message.

SELECT DISTINCT 

                      ARP.DisplayName0 AS [Application Name], ARP.Version0 AS Version, CASE WHEN ARP.DisplayName0 = 'Adobe Reader XI (11.0.01)' AND 
                      ARP.Version0 = '11.0.01' THEN 'Compliant' WHEN ARP.DisplayName0 = 'QuickTime' AND 
                      ARP.Version0 = '7.73.80.64' THEN 'Compliant' ELSE 'Not Compliant' END AS 'Application Status'
FROM         dbo.v_Add_Remove_Programs AS ARP RIGHT OUTER JOIN
                      dbo.v_R_System AS SYS ON ARP.ResourceID = SYS.ResourceID
WHERE     (SYS.Netbios_Name0 = @Sys_xx) AND (ARP.DisplayName0 LIKE 'Adobe Reader%' OR  ARP.DisplayName0 LIKE 'Quicktime%') 
GROUP BY ARP.DisplayName0, ARP.Version0

Desired Output

Application name   Version      Status

Adobe Reader        11.0.1       Compliant

Adobe Shockwave  10.1.3      Not Compliant

Adobe Flashplayer   N/A         Missing

June 20th, 2013 4:32pm

Your query as written, there is now way to show missing software. How could it know that you are looking for 3 or more different software titles.

You need to define what you are looking for. Then you can write a report which will allow you to display the status of a PC and if the SW title is missing.

Free Windows Admin Tool Kit Click here and download it now
June 29th, 2013 9:24pm

With some help I came up with the query listed below.  I also created a script which can auto-generate this query using a spreadsheet for input data.   I'm open for improvement suggestions.  

SELECT MIN(CASE DN.Name
                WHEN 'Adobe Reader XI (11.0.01)'
                THEN CASE ARP.Version0 WHEN '11.0.01' 
                         THEN 'Adobe Reader XI (11.0.01) is  Complaint' 
                         ELSE 'Adobe Reader XI (11.0.01) is not  Complaint' 
                     END
                WHEN 'QuickTime' 
                THEN CASE ARP.Version0 WHEN '7.73.80.64' 
                         THEN 'Apple QuickTime is  Complaint' 
                         ELSE 'Apple QuickTime is not  Complaint' 
                     END
                WHEN 'McAfee Host Intrusion Prevention' 
                THEN CASE ARP.Version0 WHEN '8.00.0202' 
                         THEN 'McAfee HIPS is  Complaint' 
                         ELSE 'McAfee HIPS is not  Complaint' 
                     END
           END) as Complaint
FROM (SELECT 'Adobe Reader XI (11.0.01)' Name UNION ALL
      SELECT 'QuickTime' UNION ALL
      SELECT 'McAfee Host Intrusion Prevention') AS DN
CROSS JOIN dbo.v_R_System AS SYS 
LEFT JOIN dbo.v_Add_Remove_Programs AS ARP 
  ON ARP.ResourceID = SYS.ResourceID AND ARP.DisplayName0 = DN.Name
WHERE SYS.Netbios_Name0 = @System_Name
GROUP BY SYS.Netbios_Name0, DN.Name



July 2nd, 2013 2:10pm

I don't know if this is a cut & pasting error but this query doesn't make any sense to me. Did you run this in Excel or SSMS?

How do you plan to use this query?

Free Windows Admin Tool Kit Click here and download it now
July 2nd, 2013 2:47pm

You're correct, there is a typo in it which I fixed.  I ran it in SSMS and you probably need to replace @system_name with an actual system name.  I'm planning on creating a report on a SQL reporting server.  I also wanted to test it as a SCCM report although I'm not sure it will work with WSQL. 
July 2nd, 2013 3:25pm

That looks a lot better and No you will not be able to do this within WQL. I have to ask, why would you want to do that anyways in WQL?

Free Windows Admin Tool Kit Click here and download it now
July 2nd, 2013 3:35pm

To run it as SCCM report.  It was just a thought, maybe not a good one.   To create a cleaner report it might be nice to have the Complaint \ Not Complaint broken out into a second column although I'm not sure it's possible. 
July 2nd, 2013 4:29pm

You can have it as a second column in a report.
Free Windows Admin Tool Kit Click here and download it now
July 3rd, 2013 7:57am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics