I saw some old collection query code from SMS 2003, it does not work when I drop it into a SCCM 2007 collection. I looked at the code and I did not find all the matching data. Here is the code:
SMS_R_System.ResourceID,SMS_R_System.ResourceType,SMS_R_System.Name,SMS_R_System.SMSUniqueIdentifier,SMS_R_System.ResourceDomainORWorkgroup,SMS_R_System.Client from SMS_R_System where Name in (select Name from SMS_R_System where ((DATEDIFF(day, SMS_R_SYSTEM.AgentTime, getdate()) >=15) and AgentName = "SMS_AD_SYSTEM_DISCOVERY_AGENT")) and Name in (select Name from SMS_R_System where ((DATEDIFF(day, SMS_R_SYSTEM.AgentTime, getdate()) >=45) and AgentName = "Heartbeat Discovery"))
This is supposed to populate a collection with machines that have not been active in AD for 15 days. What I'm trying to figure out is how to identify broken clients in SCCM 2007. I know SCCM reads AD each night and finds all kinds of machines that are no longer alive. So this code above would be great but how do I code this for a SCCM 2007 collection?