Computer names in Jamf

laurens-martens
New Contributor

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 4

Errick_Pfuhl
New Contributor III

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
Contributor III

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

Errick_Pfuhl
New Contributor III

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

 

Errick_Pfuhl
New Contributor III
#!/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)