Query device for last user to logon

Hello,

I was just wondering if there is a way to query a device to see who the last user was to logon to that system?  Does SCCM 2012 log that information?  Thanks!

August 31st, 2012 8:18pm

If you just need it for a single system, you can right click on the system, select properties, and then scroll down to last login username.

If you need to see all of them at once, you could create a query.  Here is the syntax I used to create a query to show system name and last logon user name:

select distinct SMS_R_System.LastLogonUserName, SMS_R_System.Name from  SMS_R_System order by SMS_R_System.Name


Free Windows Admin Tool Kit Click here and download it now
September 1st, 2012 12:09am

I went to properties of the client and there is nothing under 'last login.'  Something wrong with my setup?
September 3rd, 2012 6:03pm

No, there isn't anything wrong with your setup.  It's just that particular attribute, "lastlogonuser", comes from heartbeat.  If heartbeat happened to have occurred when no user was logged on, there's nothing to report.

The heartbeat query looks in WMI, in select username from win32_computersystem .  If at the time of heartbeat that attribute was blank, (or you have GPOs that prevent that attribute from being in WMI), then for you it will be blank.

"in general", ConfigMgr isn't an instant gratification for last logon user.  Most of the "concepts" about CM12 is around primary user, not last logged on user.  Have you enabled the primary user components of CM12 yet?

Free Windows Admin Tool Kit Click here and download it now
September 4th, 2012 1:06pm

Primary User Components?  I'm not sure.  I'm mostly administering SCCM 2012.  It was set up for me by a consultant.
September 4th, 2012 1:14pm

sorry, my bad term... I'm still thinking ConfigMgr 2007.  In ConfigMgr 2012 the correct term for it is "User Device Affinity", or UDA.

You may not want to change anything in this location, but if you just want to look and see what, if anything, is configured:

In your console, go to Administration, Client Settings.  Right-click and properties on "Default Client Settings".  then go look at "User and Device Affinity", and see what you have defined there.  The defaults I believe are False for both options. (automatic, and the user could set it, if they choose to go so from the control panel applet).  it is, of course, completely up to you if you want to enable either or both of those options.

In what I think of as a 'normal' company, you'd want to at least turn on 'automatically configure'.  If your users are smart (or trainable), you may want to set the "allow user to define" to True as well.  To me, a "normal" company is one where in general, one user primary uses the exact same windows computer.  If you are in a company where people go from box to box to box, then UDA doesn't do you much good in this scenario.  Read up on UDA; you can also script a relationship; but automatic is (to me) much easier; but of course it has to fit your business model.

OPTIONAL:  Instead of changing "Default Client Settings"... you may want to create a NEW Custom Client Agent Setting, and then within that, enable the UDA components.  Then, presuming you already have a collection of "only Workstations, no servers", target that new custom client agent setting to ONLY your workstations.  That way, you won't get UDA data at all on servers.  Again, depends on your business model; but "in general" UDA on a server really isn't that important.

Free Windows Admin Tool Kit Click here and download it now
September 4th, 2012 9:03pm

Hello Sherry Kissinger ,

Finally I found someone / some forum which states, "Last User Name / Logon User' is fetched from 'win32_computersystem' class of wmi. I found this info in 'Inventory.log' of a device but was not entirely sure.

I am facing a strange problem with this. Having queried 25k systems in environment 200 devices are not returning with the User data. 

Can you please suggest what can be the issue ?

Regards

 

June 24th, 2015 7:29am

Examine Win32_Computersystem on such a client and see if a username is populated. 
Free Windows Admin Tool Kit Click here and download it now
June 24th, 2015 7:31am

Hello Torsten,

I checked the below path for an issue device:

\\systemname\root\cimv2\Win32_Environment

and found the UserName (object) present. On double-clicking there were various other entries.

I thought either this class won't be present or if class is there then UseName object won't be there but it seems otherwise :(

Regards

June 24th, 2015 9:26am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics