Posted on 01-28-2022 11:47 AM
Hi,
We currently have a lot of duplicate names in our Org.
Is their an option in Jamf to add a variable to each user during enrollement?
Thanks!
Posted on 01-28-2022 12:30 PM
If you are authenticating your users at enrollment you can use the built in script parameter for assigned user name to rename devices in your org. You will need to write a naming script for the convention you want to use. Assuming Jamf pro
Posted on 01-28-2022 01:05 PM
I don't know if these variables are usable in PreStage Enrollments, but I found the page of payload variables here.
Posted on 01-28-2022 01:07 PM
I would just have the script in a policy running after enrollment complete or on recurring checkin. If it goes 15 minutes before it gets a name that shouldnt be a big deal
Posted on 01-28-2022 01:10 PM
#!/bin/sh
jssUser=$4
jssPass=$5
jssHost=$6
serial=$(ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformSerialNumber/{print $4}')
username=$(/usr/bin/curl -H "Accept: text/xml" -sfku "${jssUser}:${jssPass}" "${jssHost}/JSSResource/computers/serialnumber/${serial}/subset/location" | xmllint --format - 2>/dev/null | awk -F'>|<' '/<username>/{print $3}')
## If either the username or model name came back blank from the above API calls, exit
if [[ "$username" == "" ]]; then
echo "Error: The Username is blank."
exit 1
else
fullCompName="${username}-${serial}"
/usr/sbin/scutil --set HostName "$fullCompName"
/usr/sbin/scutil --set LocalHostName "$fullCompName"
/usr/sbin/scutil --set ComputerName "$fullCompName"
/usr/local/bin/jamf setComputerName -name "$fullCompName"
/usr/local/bin/jamf recon
sleep 30
fi
that is the script we use to do username-serial convention. Should be able to modify as needed. you will need an auditor service account in jamf to read the computer record (parameters $4 $5 for the account)