Computer Rename Using Dropdown Boxes

New Contributor III

Hi all,

I wanted to see if this is even possible, and thank you for any help or insight!

We have 3 main departments that I am managing devices for: Pharmacy, Physical Therapy, and Physician Assistants. I would to use our renaming scheme so that I can get it automated and get us closer to my ideal Zero Touch Deployment configuration.

We rename the computers based on: DEPT-USER-DEVICE

I would love to see if we could present a user with a popup or alert that contains a dropdown box for them to select their department. This would then determine the Department part, then obviously we can get the User with $3, then I care less about the device type.

So I throw this out there, can it be done?


Honored Contributor II
Honored Contributor II

@casafrancisco totally possible and something we do today. We utilize country, business unit name, and a portion of the machine serial number to name computers. I spoke about it in my JNUC preso last year and you can find a sanitized version of the script we use here:

You can walk back from that script to get to the PDF of the presentation. The slide showing the dialogs is towards the end.

Basically, we use cocoa dialog to ask for the information, then based on the info we set the name. This should do the trick to ask for the department, grab the user name and capitalize it, combine the two, and then set the name on the computer using the jamf binary.

You will obviously need to install cocoaDialog on the systems before you can run this.


# cocoaDialog path
currUser=`python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "

department=`$CD standard-dropdown --height 125 --text "Please choose the department:" --float --no-cancel --title "Department" --items "Pharmacy" "Physical Therapy" "Physician Assistant" --string-output --icon gear`
department=`echo ${department} | cut -d' ' -f2-`

case ${department} in 

'Physical Therapy')

'Physician Assistant')


## uppercase user name
currUser=`echo ${currUser} | tr [a-z] [A-Z]`

## buid computer name

# update Jamf
/usr/local/bin/jamf setComputerName -name ${computerName}

exit 0

Contributor III

Short answer is yes it can be done. In fact it can be done in just about any scripting language available. You could use Applescript or BASH but IMO Applescript's GUI presentations which BASH uses are disjointed. I would think that Xcode (Swift) or Python would be the way to go for what you describe. Here is a link you could use as the backbone to build on. This was put together by Jamf professional services and a great tool on it's own. With some Google Fu and trial and error I bet you could work out what you want to do. I am sure there are others that would recommend other approaches and there is nothing wrong that. The trick is finding what you are comfortable with and running with it.

New Contributor III

@stevewood Thanks I'll check this out! Is this the one you mentioned?

@m.donovan I'll check that out as well. Thanks!

Honored Contributor II
Honored Contributor II

@casafrancisco yes, but you'll not find a download for it there. I'm not even sure where a valid download link is, but you might do a search here on Jamf Nation for it. The developer, well the guy that took over development, took down all of the install links.