Populating Username in JSS inventory as Current Logged in User via terminal command

New Contributor II

I was working on a project for a customer workflow and came up a with a simple way to populate the Username field in a OS X devices record Username and Location field.

This one liner can be run as a script during a policy, or configured in the "Execute Command" field in the Files and Process payload of a policy.

jamf recon -endUsername $(stat -f%Su /dev/console)

Running the above command will run inventory on a client and take the username of the current logged in user and over write the "Username" field in the JSS inventory. This is intended to be used mostly in situations were LDAP services are not available and the Username value in the JSS is blank.

Hopefully this will help someone.