Skip to main content
Question

Set Name with department abbreviation and serial number

  • June 1, 2015
  • 7 replies
  • 35 views

Forum|alt.badge.img+3

Im looking for an easy way to set the computer name during the imaging process to have the department and then the serial number of the computer. Ive done some research but couldn't really find anything.

7 replies

bpavlov
Forum|alt.badge.img+18
  • Esteemed Contributor
  • June 1, 2015

You would have to script something like that.

One way I can think of, in Casper Imaging write the initials of the Dept in the computer name field then have a firstboot script that collects the computer name using and comes it with the serial number:

#Get computer name from JSS
JSSComputerName="$(/usr/bin/jamf getComputerName)"

#Get computer serial number
SerialNumber="$(/usr/sbin/system_profiler SPHardwareDataType | grep "Serial Number (system)" | awk '{print $4}')"

#Combine both computer name and serial number
NewComputerName="$JSSComputerName$SerialNumber"

#Rename computer in JSS
/usr/bin/jamf setComputerName "$NewComputerName"

Just a fair warning, I haven't tested this. And there may be other ways to tackle this as well, but it's the first thing that came to mind.


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • June 2, 2015

As I think was mentioned by someone else on another similar thread from a few months back (and I admittedly had forgotten about), the jamf binary can do this all by itself:

#!/bin/sh

prefix="department_name"

/usr/sbin/jamf setComputerName -useSerialNumber -prefix "$prefix"

The above will set the Computer name to be department+serial number. You could add some delimiter into the prefix if needed to have some separation, like a dash for example.


bentoms
Forum|alt.badge.img+35
  • Hall of Fame
  • June 2, 2015

@rcs336 What @mm2270 is what I usually recommend.

One thing though, are you binding to AD? If so, you may want to think carefully about name length & also maybe have serial 1st as then it should be unique (incase the department gets abbreviated).


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • June 3, 2015

I just tried what you suggested @mm2270 and not sure what I did wrong. I used the JSS Management Site and added a script then included that scrip in my configuration. Is there any more info you could give me?


bentoms
Forum|alt.badge.img+35
  • Hall of Fame
  • June 4, 2015

@rcs336 "JSS Management Site"?


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • June 4, 2015

The website you use to manage casper settings. Sorry not sure what else to call it.


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • June 4, 2015

That's often referred to as just the JSS (JAMF Software Server)
As for adding it in your configuration, I assume you mean your Casper Admin imaging configuration? If so, make sure the script is running after the Mac boots into the imaged OS. Also, you may want to check around on here for best practices regarding system naming scripts and imaging since some of these things need to be done in an exact order and can mess up the process if done too early (or even too late)
Since I don't use Casper Imaging (using DeployStudio with a custom post image process) its hard for me to guide you on exactly when this should run.