Skip to main content
Question

Computer names in Jamf

  • January 28, 2022
  • 4 replies
  • 26 views

Forum|alt.badge.img+1

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!

4 replies

Forum|alt.badge.img+4
  • Contributor
  • January 28, 2022

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


Fluffy
Forum|alt.badge.img+10
  • Honored Contributor
  • January 28, 2022

I don't know if these variables are usable in PreStage Enrollments, but I found the page of payload variables here.


Forum|alt.badge.img+4
  • Contributor
  • January 28, 2022

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

 


Forum|alt.badge.img+4
  • Contributor
  • January 28, 2022
#!/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)