Last logged in user details

srathore
New Contributor

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 1

macninja_IO
New Contributor III

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