Find last logged on user by NetBIOS name – SCCM Query

sccm logo
SCCM Logo

Table of Contents

Estimated reading time: 2 minutes

I’ve been asked a lot of questions about the various ways of using queries and there are almost no limits to what you can do with a query and of course, you can then go on and use these queries for creating collections or just to supply you with the information you require.

I have created some very basic queries so far on previous posts that are available below:

Last logged on user query – All Systems

Find system by last logged on user – Using a Username prompt

Another variation on these basic queries that I’ve been asked to provide is to prompt for a computer name (in this query I’ll be using the NetBIOS name) which can be entered to provide the last logged on user and other information for that machine.

The query to do this is below:

select distinct 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
where
SMS_R_System.NetbiosName = ##PRM:SMS_R_System.NetbiosName##

Again, there is a lot of junk information that will be provided but I have put that in so that you have a choice on the information you want. If there is anything in there you do not want, just remove it from the query.

More Queries

Our full range of SQL and WQL Collection queries are available here.

Feedback

If you have any questions or feedback about this post, or if you would like us to create any queries for you, please go ahead and leave us a message below in the comments section and we will get back to you as quick as we can.

Share this content:

Click to rate this post!
[Total: 1 Average: 5]
Avatar for Andrew Armstrong

About Andrew Armstrong

Founder of TechyGeeksHome and Head Editor for over 15 years! IT expert in multiple areas for over 26 years. Sharing experience and knowledge whenever possible! Making IT Happen.

View all posts by Andrew Armstrong

Leave a Reply

Your email address will not be published. Required fields are marked *