Capturing First name, Surname and email address?

MatG
Contributor III

Hello,

Something that bugs me about our inventory is we are not collecting clear user information so when I run a report its really hard to identify users without a further look up on one of our internal systems.

Our Macs are AD bound and login is an assigned 4 letters and 3 numbers combination which have no reference to a users real name and this what I see in a JSS report.

What is a good way to capture a users first name/last name and email address? We don't use Apple mail but MS Outlook which the users setups if that helps.

5 REPLIES 5

dan-snelson
Valued Contributor II

We use the following Update Inventory script in most policies instead of the built-in Maintenance payload Update Inventory option:

#!/bin/sh

echo "*** Updating inventory ***"

# Get the logged in users username
loggedInUser=$(stat -f %Su "/dev/console")

echo "Running inventory update for ${loggedInUser} ..."

if [ ${loggedInUser} == "root" ]  || [ ${loggedInUser} == 'YourLocalAdminAccountUsernameGoesHere' ] ; then

    /usr/local/jamf/bin/jamf recon

    echo "Finished running inventory update"

else

    # Run recon, submitting the users username which as of 8.61+ can then perform an LDAP lookup
    /usr/local/jamf/bin/jamf recon -endUsername ${loggedInUser}

    echo "Finished running inventory update for ${loggedInUser} ..."

fi


exit 0

m_donovan
Contributor III

If you have an LDAP server setup in the JSS you can pull the info using jamf recon -endUsername @@@@@. There is a 2015 JNUC video "Solving real-world problems from the command line" or something like that. It explains how to pull the currently logged in user and send that to the JSS with the recon command.

dan-snelson
Valued Contributor II

You could test this in Terminal by issuing the following two commands:

loggedInUser=$(stat -f %Su "/dev/console")

… then …

/usr/local/jamf/bin/jamf recon -endUsername ${loggedInUser}

Then validate that the JSS shows the expected user information.

MatG
Contributor III

Great responses. Thanks :)

danny_gutman
New Contributor III

I'm only able to lookup via email address, but my script to automatically assign users to machines gets loggedinusername, which is usually first initial last name; results in no lookup.

Anyone find a way around this?