Naming Convention : DEP / Self Initiated

Eskobar
Contributor

Hello,

1) We want to name our Macbooks based on below criteria: 

  • Prefix + 5 digits 00001 --> 99999.
  • No duplicate should be created.
  • Process should be silent or at least automated.

2) We want as well to rename already enrolled computers using same criteria:

  • Prefix + 5 digits 00001 --> 99999.
  • No duplicate should be created.
  • Process should be silent or at least automated.

We intend to apply this naming convention on:

  • Most machines are DEP Enrolled.
  • Some are Self-Initiated

Jamf Pro looks limited in this context.

Any ideas ?

 

2 ACCEPTED SOLUTIONS

marcelp
New Contributor II

line after id cuts out the digits. You can set your Prefix in the line above

getinfo=$(jamf recon)

PREFIX="YOURPREFIX"
id=$(awk -F'<computer_id>|</computer_id>' '{print $2}' <<< "$getinfo" | xargs)
digits=$(echo 00000$id | tail -c 6)

jamf setComputerName -name "$PREFIX-$digits"
jamf recon #this is only needed for immidiate update in jamf inventory

 

View solution in original post

Eskobar
Contributor

Hi @marcelp 

I rather edit the script as shown. This works just fine. Thanks so much for you valuable help.

tt.png

Warmest regards,

View solution in original post

12 REPLIES 12

Eskobar
Contributor

Hello @Jannifer2021  

Nice to meet you. Any Idea about my request ? 

marcelp
New Contributor II

How about using Jamf Pro Computer ID as the number?

 

 

getinfo=$(jamf recon)

id=$(awk -F'<computer_id>|</computer_id>' '{print $2}' <<< "$getinfo" | xargs)
digits=$(echo 00000$id | tail -c 6)

jamf setComputerName -name "PREFIX-$digits"
jamf recon #this is only needed for immidiate update in jamf inventory

 

 

 This will be a unique value. It's also useful for administrators as you know the URL for computer object in jamf from hostname.

jcarr
Release Candidate Programs Tester

A unique arbitrary value may be problematic.  For any value that's not tied to a physical attribute of the device (e.g. WiFI or BT MAC address, serial number), there needs to be a source of truth.  If your devices have asset tags, then there should be database (or at the very least a spreadsheet) with a 1:1 correlation of serial number to asset tag.  This could be used to set the device names based on the asset tag value.

 

@marcelp 's solution uses an arbitrary unique value, but has the added advantage that Jamf Pro already knows what that value is without first needing to upload a table of values via the MUT.

 

If the goal is simply a unique name with no PII (i.e. something other than "Escobar's MacBook Air"), you could just use your prefix followed by the WiFi MAC address (this example removes the ":" to clean it up a little):

 

/usr/local/bin/jamf setComputerName -name "Mac-$(ifconfig en0 | awk '/ether/{print $2}' | tr -d :’)"

merps
Contributor III

As others have suggested, the Jamf Pro Computer ID seems logical if you need a number for some reason.

I also like the suggestion of MAC Address, or you could use SerialNumber:

/usr/local/bin/jamf setComputerName -useSerialNumber -prefix "PrefixHere-"

 

jcarr
Release Candidate Programs Tester

Serial Number has the added benefit that it is persistent through a service event (for macOS devices anyway) where WiFi MAC address will change if the device requires a new logic board.

mm2270
Legendary Contributor III

The only disadvantage I can think of in using the Jamf Computer ID as the numerical source is in the rare case of a device being deleted from Jamf and then re-enrolled. It will get a new ID in Jamf.

However, as long as your computer naming policy re-runs on the re-enrolled Mac (and it should if set up correctly), it will use the new ID and rename the Mac accordingly. Otherwise, using the Jamf ID seems like a pretty good solution to me. It will always be unique in your Jamf instance.

Eskobar
Contributor

guys, thanks for all details. We are using name convention based on a prefix + 5 digits for all company devices.

Thus, using the computer ID in Jamf should be the best scenario. 

@marcelp I scoped my mac in a policy linked to your script. My hostname is: Prefix00000. What's is missing in order to replace the last zeros by the Jamf computer ID?

Eskobar
Contributor

Issue is my hostname changed to PREFIX00000 looks like something is missing with:  

id=$(awk -F'<computer_id>|</computer_id>' '{print $2}' <<< "$getinfo" | xargs)

marcelp
New Contributor II

line after id cuts out the digits. You can set your Prefix in the line above

getinfo=$(jamf recon)

PREFIX="YOURPREFIX"
id=$(awk -F'<computer_id>|</computer_id>' '{print $2}' <<< "$getinfo" | xargs)
digits=$(echo 00000$id | tail -c 6)

jamf setComputerName -name "$PREFIX-$digits"
jamf recon #this is only needed for immidiate update in jamf inventory

 

Hi @marcelp 

This works just fine for 90% of our fleet. I have a remark though:

When client have network issue, the script assignt default name to machine locally & jamf: prefex + 00000!

jamf log error:

tx.png

Can we add a script line to check client network before running ? any suggestion ?

Thanks in advance

marcelp
New Contributor II

I would make a smart group with:

Computer Name like prefix

And scope the policy with it. That way it reruns if it fails.

Eskobar
Contributor

Hi @marcelp 

I rather edit the script as shown. This works just fine. Thanks so much for you valuable help.

tt.png

Warmest regards,