Let’s find out SQL query to find out SCCM clients registered within last 60 days. In this post, we will find out the different options to find out SCCM client registration time and last scan hardware inventory information, etc.
You can create a collection of WQL queries also using similar logic. You can create dynamic collections using the easiest method to create WQL queries. I have also shared some of the best practices that you will need to follow before creating collections with WQL queries.
There are a lot of SCCM default reports available to help SCCM admins to get more data. I recommend going through the list of ConfigMgr default reports before trying to create a custom SQL report similar to the one explained in this post.
SMS_UUID_Change_Date0 Good for SCCM Client Registration Tracking?
As per my analysis, yes. The SMS_UUID_Change_Date0 is one of the easiest options to track SCCM client registration date and time. You can use the Creation_Date0 value also to track the registration of client devices. Even though technically it’s not client registration. I think Creation_Date0 helps to store the date and time when DDR for that device is created.
In my opinion, it’s better to go with the UUID change date to track the registration of SCCM clients. But you are the best judge for your environment. It’s worth noting the following points:
- If you have enabled AD discovery methods, then it’s not ideal track client registration with Creation Date value because the AD system discovery witll create the DDR for the device during the discovery process.
- UUID of the device will get changed during client cert and smscfg.ini regeneration processes .
- I have not validated UUID change date value with respect to tenant attach scenarios.
SQL query to find out SCCM clients registered within last 60 days
You can have several different combinations of queries with SMS_UUID_Change_Date0, Creation_Date0, and LastHWScan properties from the view called v_R_System. I have selected the following query to get more accurate data in the lab environment.
As I mentioned in the above section, you are the best judge for your environment. Let’s follow the steps mentioned below to find out SCCM clients registered within last 60 days.
- Open the SQL Management Studio.
- Connect your Database Engine.
- Right Click on your database CM_XXX and click on ‘New Query’
- Copy the following SQL query to find the report of client registration date details.
- Click on the Execute button.
select ResourceID, Netbios_name0, SMS_UUID_Change_Date0, Creation_Date0 FROM v_R_System where SMS_UUID_Change_Date0 <= Dateadd(day, -1, getdate()) and SMS_UUID_Change_Date0 > Dateadd(day, -60, getdate())
NOTE! – UUID property value is set to NONE if there is no client installed on a system record already present in SCCM DB.
SCCM Query to Find out Clients Registered before 60 days
Now, let’s find out client devices that are registered to SCCM before 60 days using the following SQL query. You can make it more complex with the last hardware inventory property to get more accurate values. However LastHWscan value is not mandatory to get the details of clients that are registered before 60 days from now.
You can use the steps mentioned in the above section of the post and use the following query to get the details of the devices registered before 60 days. SQL query to find out SCCM clients registered within last 60 days is already shared in the above section of the post.
select h.ResourceID, h.Netbios_name0, t.LastHWScan, h.SMS_UUID_Change_Date0, h.Creation_Date0 FROM v_R_System h INNER JOIN v_GS_WORKSTATION_STATUS t ON h.ResourceID = t.ResourceID where h.Creation_Date0 <= Dateadd(day, -60, getdate()) and h.SMS_UUID_Change_Date0 <= Dateadd(day, -60, getdate()) and t.LastHWScan <= Dateadd(day, -60, getdate())
About Author -> Anoop is Microsoft’s Most Valuable Professional Award winner from 2015 on the technologies! He is a Solution Architect on enterprise device management solutions with more than 20 years of experience (calculation done in 2021) in IT. He is Blogger, Speaker, and Local User Group Community leader. His main focus is on Device Management technologies like Configuration Manager, Windows 365 Cloud PC, Intune, Azure Virtual Desktop, Windows 10, and Windows 11.