Find system by Last Logged on User Query for SCCM
If you need to find a machine for a particular user in your business using SCCM, one way you can do it is to
use a custom query to find the machine that relates to the last logged on user.
This means that you can run this query, it’ll prompt for a username, enter the username and it’ll then bring back the computer of which the entered username last logged into.
The query below is the full code to bring back all sorts of information, you can strip this right back if you like to just bring back simple information like username and machine name…
If you wish to view just a list of last logged on users and then be able to search on that information, a slightly amended version of this code is available here:
There is also a query that you can use that will prompt for a NetBIOS name and supply you with all the information you require:
The query code to do this is below:
select <br /> SMS_R_System.LastLogonUserName, <br /> SMS_R_System.Name, <br /> SMS_R_System.SMSAssignedSites, <br /> SMS_R_System.Client, <br /> SMS_R_System.IPAddresses, <br /> SMS_R_System.IPSubnets, <br /> SMS_R_System.MACAddresses, <br /> SMS_R_System.OperatingSystemNameandVersion, <br /> SMS_R_System.ResourceDomainORWorkgroup, <br /> SMS_R_System.LastLogonUserDomain, <br /> SMS_R_System.AgentName, <br /> SMS_R_System.AgentSite, <br /> SMS_R_System.AgentTime, <br /> SMS_R_System.SNMPCommunityName, <br /> SMS_R_System.SystemRoles, <br /> SMS_R_System.SMSUniqueIdentifier, <br /> SMS_R_System.ResourceId, <br /> SMS_R_System.ResourceNames, <br /> SMS_R_System.ResourceType, <br /> SMS_R_System.NetbiosName <br /> from <br /> SMS_R_System <br /> where <br /> SMS_R_System.LastLogonUserName = ##PRM:SMS_R_System.LastLogonUserName## <br />
HOW DO I CREATE THE SSRS REPORT?
We have now created a guide that will help you to create your SSRS reports based on the data that this guide will pull into the Configuration Manager database.
You can access this guide by clicking the link below:
If you have any problems with any of the above, then please leave your comments and questions below using our Disqus system and we will try to get back to you as soon as we can.
We also like to hear back any success stories too, so if you have used our guide and found it helpful, we would love to hear from you.