add Email attribute Jamf - script

Contributor II

I have the following scripts for updating Jamf attributes. But I would like to add an also email address

#! /bin/bash
sudo jamf recon -endUsername $3

#Discover last logged in username
lastUser=`defaults read /Library/Preferences/ lastUserName`

# Get the Full Name of the last logged in user
fullName=$(dscl . read /Users/$lastUser RealName | grep -v RealName | cut -c 2-)

# Add the users full name to the computer record in the JSS
jamf recon -realname "$fullName"

exit 0

My Idea is that is I have the lastusername I could also use this for to add the email attribute, if I could add a suffix. So if last username in "Myname" - would it somehow be possible to add a attribute to update email in jamf taking the last username and then adding ""
Maybe a little tricky way of doing it, but we have no ldap and email adress could be usefull to have in Jamf


Valued Contributor
jamf recon -email "$lastUser"

should technically work, as long as you're sure that people's usernames are the same as their email-alias.