SCCM – Last logged on user query – All Systems

sccm logo

Last updated on April 16th, 2023 at 11:26 pm

Read Time:1 Minute, 21 Second

If you are looking for a query that will display all machines and their last logged on user, the below will do this for you without any prompts. This allows you to search on the data to find what you would like across the information provided by the query.
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 use this same query but be prompted for a user name of a last logged on user and then be supplied with that users machine information, a slightly amended version of this code is available here:

Find system by Last Logged on User Query for SCCM

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:

Find last logged on user by NetBIOS name

The query code to do this is below:

select
SMS_R_System.LastLogonUserName,
SMS_R_System.Name,
SMS_R_System.SMSAssignedSites,
SMS_R_System.Client,
SMS_R_System.IPAddresses,
SMS_R_System.IPSubnets,
SMS_R_System.MACAddresses,
SMS_R_System.OperatingSystemNameandVersion,
SMS_R_System.ResourceDomainORWorkgroup,
SMS_R_System.LastLogonUserDomain,
SMS_R_System.AgentName,
SMS_R_System.AgentSite,
SMS_R_System.AgentTime,
SMS_R_System.SNMPCommunityName,
SMS_R_System.SystemRoles,
SMS_R_System.SMSUniqueIdentifier,
SMS_R_System.ResourceId,
SMS_R_System.ResourceNames,
SMS_R_System.ResourceType,
SMS_R_System.NetbiosName
from
SMS_R_System

If you have any questions about this, feel free to leave a comment.

Avatar for Andrew Armstrong

About Post Author

Andrew Armstrong

Founder of TechyGeeksHome and Head Editor for over 15 years! IT expert in multiple areas for over 23 years. Sharing experience and knowledge whenever possible! Making IT Happen.
administrator
Click to rate this post!
[Total: 0 Average: 0]

Free Subscription

If you want to be notified when we post more quality guides like this one, sign up to our free subscription service and you will receive an email when a new post is live.

Join 545 other subscribers.

No need to worry, we will not be filling your inbox with spam and you can unsubscribe anytime you like.


Leave us a message...

This site uses Akismet to reduce spam. Learn how your comment data is processed.