Skip to main content
Question

Last logged in user details

  • November 21, 2016
  • 1 reply
  • 65 views

Forum|alt.badge.img+3

I'm looking for an Extension attribute which can collect ComputerName and respective last logged in user name.
The answer might already be available around the list somewhere, but I haven't had any luck finding it... tried to find out in Jamfnation EA lists but again no luck.
Can somebody help me out in this?

Thanks,
Sourabh

1 reply

Forum|alt.badge.img+8
  • Contributor
  • November 21, 2016

Hi Bob

We use this

!/bin/bash -v

LASTUSER=$(ls -l /dev/console | cut -d " " -f4)

FULLNAME=$(dscl localhost -read /Active Directory/YOUREDOMAIN/All Domains/Users/$LASTUSER | sed -n '/RealName/{n;p;}' | cut -c 2-)

if [ "$LASTUSER" == "" ]; then echo "<result>No logins</result>"
else

echo "<result>$_FULLNAME_</result>"

With this you get both username and Full Name.
You can just edit it top exclude the full name.

/Michael