After Active Directory System Discovery or Network Discovery runs, it is handy to see exactly which machines have just appeared in Configuration Manager for the first time. You might want to catch new builds that still need the client, check that a batch of new laptops has landed, or simply keep an eye on what is turning up in your environment. This guide gives you a WQL query for devices discovered in the last 24 hours, explains why the property you filter on matters, and shows how to turn it into a collection that keeps itself up to date.
The Query: Devices Discovered in the Last 24 Hours
Every resource record in Configuration Manager has a CreationDate, which is the date and time the record was first created in the site database. Filtering on that gives you genuinely new machines:
select SMS_R_System.Name, SMS_R_System.ResourceDomainORWorkgroup, SMS_R_System.Client, SMS_R_System.CreationDate
from SMS_R_System
where DateDiff(hh, SMS_R_System.CreationDate, GetDate()) <= 24
To run it, go to Monitoring > Queries, choose Create Query, give it a name, click Edit Query Statement, then Show Query Language and paste the WQL in. Once saved, right-click the query and choose Run.
Why CreationDate and Not AgentTime?
The earlier version of this post filtered on AgentTime. That property is a list of the last time each discovery method found the machine, so it gets refreshed every time discovery runs. A query on AgentTime therefore returns machines that were rediscovered recently, which on a busy site can be nearly everything. CreationDate only changes when the record is first created, so it answers the question you are actually asking.
Getting a More Precise Window
DateDiff(hh, ...) counts hour boundaries crossed, not exact elapsed time, so results around the 24-hour edge can be slightly generous. If you need a tighter cut-off, count minutes instead:
where DateDiff(mi, SMS_R_System.CreationDate, GetDate()) <= 1440
Change 1440 to suit. For the last seven days you could use DateDiff(dd, SMS_R_System.CreationDate, GetDate()) <= 7. If your results look an hour or so out, it is usually a time zone difference between how the site stores the date and the server’s local time, so widen the window slightly rather than chasing it.
Turn It into a Self-Updating Collection
A query is good for a quick look. If you want an ongoing list you can deploy to or report on, create a device collection with a query rule. Collection queries must return the standard resource columns, so use this version:
select 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 DateDiff(hh, SMS_R_System.CreationDate, GetDate()) <= 24
- In Assets and Compliance > Device Collections, create a new device collection limited to All Systems (or a narrower collection if you prefer).
- Add a Query Rule, edit the statement and paste the WQL above.
- Set a full update schedule, for example every few hours. Incremental updates pick up new resources quickly, but machines only leave a time-based collection when a full evaluation runs, so a full schedule is what keeps it accurate.
Our guide to using SCCM collections and query rules effectively covers evaluation schedules and limiting collections in more detail.
Useful Variations
New machines that still have no client
Add a client check to find newly discovered devices that need a client push:
where DateDiff(hh, SMS_R_System.CreationDate, GetDate()) <= 24
and (SMS_R_System.Client is null or SMS_R_System.Client = 0)
For a wider view of every device without the agent, see our no ConfigMgr client installed query.
Prefer SQL for reports?
If you are building an SSRS report or querying the database directly, there is an equivalent SQL query for newly discovered devices that uses the v_R_System view.
If It Returns Nothing
- Discovery has not run. Machines are only created in the database when a discovery cycle or client registration picks them up, not the moment they join the domain. Check the schedule under Administration > Hierarchy Configuration > Discovery Methods, and enable delta discovery if you want new AD objects found within minutes.
- The machine already existed. A rebuilt device that keeps its name and AD object may reuse its old record, so it will not show as new.
- Your limiting collection is too narrow. If the collection is limited to something other than All Systems, new devices outside it will not appear.
FAQ
Does this work in current branch Configuration Manager?
Yes. SMS_R_System.CreationDate has been part of the class since ConfigMgr 2012 and is still there in current branch.
Can I use it in an Intune co-managed environment?
It works for anything Configuration Manager discovers. Devices that are only in Intune and never discovered by ConfigMgr will not appear.
You can find more ready-made queries in our SCCM SQL and WQL query library.
Resources
- query
- our SQL & WQL query library
- Browse our Windows Admin Toolkit picks on Amazon
- Crucial P310 1TB NVMe SSD
- Corsair Vengeance 32GB DDR5 RAM
- Corsair RM750e power supply
Discover more from TechyGeeksHome
Subscribe to get the latest posts sent to your email.