Grab user information from Local Account

mitulpatel2003
New Contributor

Hey folks,
Was wondering if there is a way to automatically upload Local user information from the machine to JSS?

The Mac already collects Full Name and Short Name, and we just want it to be able to upload that to JSS so the User and Location fields get populated with Full Name and Shortname

Thoughts?

Thanks in advance!

2 REPLIES 2

stevewood
Honored Contributor II
Honored Contributor II

@mitulpatel2003 sure you can do this. You'll need to use dscl to pull the info from the local machine and the jamf binary with the recon verb to do so. This is a rough, not tested, script you could use. Just one way to do it.

#!/bin/bash
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
firstName=`dscl . read /Users/${loggedInUser} FirstName | /usr/bin/awk '{ print $2 }'`
lastName=`dscl . read /Users/${loggedInUser} LastName | /usr/bin/awk '{ print $2 }'`
fullName="${firstName} ${lastName}"
shortName=`dscl . read /Users/${loggedInUser} RecordName | /usr/bin/awk '{ print $2 }'`

jamfCall="jamf recon -endUsername ${shortName} -realname '${fullName}'"

${jamfCall}

mitulpatel2003
New Contributor

@stevewood Thanks so much! going to try this out later today!
Thanks again!