API: Use History >Computer Usage Logs> Username at last login

winningham_2
Contributor

I have been asked to script populating /computers/name/MyComputer/subset/location/username/ +with the last person who logged in as a run-once API script. I was thinking I would grab from the JSS the +History >Computer Usage Logs> Username at last login field and use that to put to username but I cannot seem to find that info in the API. I also thought about capturing echo $3 at login (excluding some admin-side accounts) for a run-once to populate that field or grabbing the results of "last" and then putting it up to the JSS. I don't know...

Anyway, does any body have any idea on where History >Computer Usage Logs> Username at last login info is hanging out or an opinion on how I might go about scripting this?

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

I would just script getting the name of the last user. There's already an Extension Attribute template for this in the JSS that you can snag the code from. We have that EA added in to our JSS and it works fine on all versions of OS X we manage (10.6.x - 10.9.x)

View solution in original post

3 REPLIES 3

mm2270
Legendary Contributor III

I would just script getting the name of the last user. There's already an Extension Attribute template for this in the JSS that you can snag the code from. We have that EA added in to our JSS and it works fine on all versions of OS X we manage (10.6.x - 10.9.x)

winningham_2
Contributor

@mm2270 Of course parsing the xml to grab extension attributes has to be the worst deal ever if working inside of BASH. Holy cow. But this will certainly help, thanks.

mm2270
Legendary Contributor III

Indeed! I do it in scripts when its necessary, as in, the only place the data exists is in the API. But if I can get the same information from the Mac itself I go that route. Ten times easier than working with the xml from the API in bash.