How to name new OS X devices for DEP?

St0rMl0rD
Contributor III

Hi everyone,

Where is the option of setting the names for PreStage Enrollment of OS X computers that enrol over DEP? We see the option of naming for mobile devices, but it's not there for computers.

Thanks!

9 REPLIES 9

adamcodega
Valued Contributor

There is currently not a way of naming devices within the pre-stage enrollment. I have a script that sets the computer name based on the username upon first startup.

For computers we can automate names with a script but I assume we get to do it via a pre-stage enrollment on mobile devices since there isn't another automated way.

gregleeper
New Contributor

@adamcodega do you mind sharing this script with us? I've been searching on here for something similar to this but haven't been able to find much.

adamcodega
Valued Contributor

Sure thing it's on my GItHub.

The script can be pretty simple it just depends on your naming scheme. We like to use first initial last name to make it easy, so we pull that from the user full name. Then we set the computer name with the JAMF framework.

My script then uses CocoaDialog to ask the user (presumably an IT tech) which department to put the computer into and sets that using the JAMF framework.

Then we run a policy and recon refresh so software and printers install and the IT tech can install anything else via Self Service.

There's a few issues I need to investigate. One, I've heard using the JAMF framework to set the computer name isn't identical to using scutil three times.

sudo scutil --set ComputerName "newname"
sudo scutil --set LocalHostName "newname"
sudo scutil --set HostName "newname"

Secondly, I haven't added commands to the script to set system updates to install and to install any pending updates. I'll need to play with that to make the startup, see an update, install an update, continue where enrollment left off routine work well.

gregleeper
New Contributor

Thanks, Adam. That will be a huge help.

adamcodega
Valued Contributor

Oh, also, the CocoaDialog dropdown box needs a --height 150. I haven't pushed my changes to my GitHub yet.

daniel_behan
Contributor III

I specified how I've been handling it in the post below:

https://jamfnation.jamfsoftware.com/discussion.html?id=13378

gregleeper
New Contributor

@adamcodega we have a lot students with the same first initial and last name. How can we change the line that pulls the first initial to pull the full first name instead? I've been trying to figure this out and can't. This is the line below that I'm referring to. Thanks!

get first initial

finitial="$(echo $name | head -c 1)"

adamcodega
Valued Contributor

@gregleeper Head is being used to take out the first byte in the variable, meaning the first letter of the first name.

If you look at last name variable, we are using cut, telling it that a space is the delimiter with -d, and asking it to cut and then show us the second value, because we used -f 2

If you use -f 1 you'll get the first value instead, getting you the first name.

fn="$(echo $name | cut -d   -f 1)"

gregleeper
New Contributor

Thanks for explaining how you got those values. Learning this stuff can really help out in the future.