Computername creation with specific format

ESK-IT-Infra
New Contributor II

Hi all,

I'm pretty new to JAMF but at my company, we need to make our Macs computernames similar to the ones of our Windows machines.
Let's say Windows machines are named like WIN180001 where WIN is fixed, 18 is the current year and 0001 is an increasing number per new machine, reset per year.

Did someone already come across something similar? I found a lot of articles on creating a script to use the serial or but never with some increasing number.

I'm looking for a solution where we can create MAC180001 for instance now.
The fixed part and the year should be easy, but the incremental part is difficult for me.
Is there a way to get the last installed device and increment the last 4 digits with 1 for this? Or is there a easier solution for this?

Your help is more than appreciated :)

We're almost there with our setup, this is just one of the remainders on our to do list.

Thanks,

Stijn.

5 REPLIES 5

rderewianko
Valued Contributor II

Okay, this sounds like a fun task.

Two ways that you could go about it. One, is hopping on github and finding a hit counter, and having every client curl that site (which then increments upon every hit)
https://github.com/coopermaa/hit-counter-demo running something like that... you'd then curl it, and get a response... based on the response you scrape for the value.

Or if you've got a simple webserver running PHP https://github.com/ericsizemore/simple_counter this may work too.

The second, maybe using something like:
Starting with something like: https://www.jamf.com/jamf-nation/discussions/7052/how-to-obtain-the-value-of-a-certain-extension-attribute-through-the-api

and then incrementing that value locally and then updating the ea... (this could get messy if you've got mulitple machines imaging at the same time)

ryan_ball
Valued Contributor

How about mounting a SMB share somewhere during imaging, where a file can be written to, read the file which contains a list of numbers and greping the first uncommented line to grab the next available number. Than just comment out that line in the file. This could be done pretty easily programmatically.

Look
Valued Contributor III

We have an Asset Database matching serial number with a number of other useful pieces of info like hostname, owner, cost centre etc...
The guys in charge of it made an API for it where you simply pass it the serial number and it returns all the fields.
I call this from a script on enrollment which then names the machine prior to binding to AD.

ESK-IT-Infra
New Contributor II

I really like this :) This might really help me further!
I'll go through the options and update you on the progress I made here, thanks to your help!

There are nice solutions here, I'll need to find the best one for us, but I'm really happy with the current replies.

Other possibilities are still more than welcome too of course.

Stijn.

ESK-IT-Infra
New Contributor II

I really like this :) This might really help me further!
I'll go through the options and update you on the progress I made here, thanks to your help!

There are nice solutions here, I'll need to find the best one for us, but I'm really happy with the current replies.

Other possibilities are still more than welcome too of course.

Stijn.