Change the Mac Device name

saeid_agheli
New Contributor III

Hi Guys

we connected JAMF connect to Okta but after user enrollment we see the device name its Macbook how we can able rename that to user first and last name base on okta information 

8 REPLIES 8

mickl089
Contributor III

you need a script running through the enrollment process, search for it, there are many solutions ;-) 

Do you have one ?

 

McAwesome
Valued Contributor

I think you should really reconsider that naming scheme.  You will be broadcasting that user's name to every network they connect to and to every device around them that wants to connect.  It's a huge privacy issue, and one that doesn't seem to have any pro to balance that out.

mm2270
Legendary Contributor III

I agree with @McAwesome. I see this type of question a lot here. Some people are not aware that it's possible to include a lot of user details in a computer record in Jamf, without needing to have that info in the computer name itself. If the concern is "how do I know who is using this Mac?", then the answer to ensure you correctly populate the User & Location Details section for the device, not to use the user name in the computer name.

There are some automated ways of doing this, and some scripted processes, but I think no matter what auth or IdP you use, it's possible to pull some of this info and add it to the computer record. It's a much more reliable (and safer) way of having  user details to search on.

brockwalters
Contributor II

The way the reset name feature in Jamf works is: whatever string is in the computer name field in Jamf at the time of inventory collection will become the name of the comptuer as if it were set with

scutil --set ComputerName someName

There are several ways of populating these names in the Jamf computer records: you can click through & find the ones you want to set in the GUI, you can use Inventory Preload (look up in Jamf Pro docs...) you can write an API script to upload computer names to computer records based on some other matching attribute like Jamf Computer record object ID, or serial number or hardware UUID, or, etc...

saeid_agheli
New Contributor III

thanks all guys 

i use this Script now and working fine but adding Device model to end of the name do you have any suggestions about that 

 

 

saeid_agheli
New Contributor III
#!/bin/bash



# Set variables



# Get the last logged in user
lastLoggedInUser=`defaults read /Library/Preferences/com.apple.loginwindow lastUserName`



# Get Model Name of computer
modelName=`system_profiler SPHardwareDataType | grep "Model Identifier" | awk '{print $3}' | sed 's/[0-9]*//g' | tr -d ','`



# Get original name of computer
oldComputerName=`scutil --get ComputerName`



# Generate new computer name
computerName=$lastLoggedInUser-$modelName



# Set new computer name locally
scutil --set ComputerName $computerName



scutil --set HostName $computerName



scutil --set LocalHostName $computerName



# Set the computer name in Jamf to reflect what is set locally on the computer
/usr/local/bin/jamf setComputerName -name $computerName
/usr/local/bin/jamf recon



echo "Computer name has been changed from $oldcomputername to $computerName"



exit 0

brockwalters
Contributor II

I guess question 1 is which model? Model identifier, model number, model marketing name?