Record previous computer names?

rleatherwood
New Contributor II

Every once in a while we'll come across a computer that gets moved from a classroom to another classroom or even another school without us knowing. When we go through each year to update our computers we name the computers according to where they are

SchoolName-RoomNumber-ComputerNumber

So something like
HighSchool-101-01

It makes it easier for us when we need to push specific things out to specific rooms. (Printers and such).

But, if a computer gets moved down the road we'd like to be able to look back at the computer name history, is there any.

I was trying to make an extension attribute for this, but the farthest I could get would be to write the computer name to the extension, but then what? Everytime we image the computer it would just write over that name. Is there a way to have an extension attribute add the next computer name while keeping the old computer name in there? I don't care if it has multiple names in there, and maybe keep up to 5 names for the past 5 names it held?

4 REPLIES 4

mm2270
Legendary Contributor II

You would have to have your Extension Attribute script write computer names to a local file, but only if the name isn't already in the file. So IOW, first time it records the name, it writes to, or creates a new file on the Mac with the name, and potentially other data like the date it was recorded if that is relevant information.

Later each time the script runs, it needs to first look for the existence of that file and check its contents to see if the current computer name is already contained in it. If it is, it can just read the contents of the file for reporting back as the EA result.
If its not there, the script can write in the new computer name to the file (append) and then read back the contents of the file as its result.

There are other ways this can probably be done, such as a manual EA that you add the value in by hand into the computer record, but that isn't going to be automated in any way.

I was going to say initially that the Computer/Software change history tab may contain that, but for one, it does not record the computer name from what I can tell. And two, it only retains so much history before older events get lost, so eventually you'd lose the name history even if it recorded that.

alexjdale
Valued Contributor III

The only way I can think to do this to survive re-imaging is to have an extension attribute that is populated by script, but using an API call to read the existing attribute (list of past names) and then return the same attribute with the new name added (and some other code to keep it from doing this every inventory time, only if the local computer name changes). I don't think you would lose any history as a result of re-imaging unless you delete the computer record from the JSS.

This is a theory, I haven't actually done this.

mm2270
Legendary Contributor II

Ah, are we talking about re-imaging these Macs, or are you just repurposing them as-is (no nuke & pave) to another group? If they are being re-imaged, then forget everything I mentioned above and read what @alexjdale posted. Writing to a local file will get wiped on re-image (if you are blowing the contents of the drive away in the process)

rleatherwood
New Contributor II

Thx for the replies

Yeah they our machines are going to be re-imaged. This isn't a huge priority for us right now, while it would be nice to have every once in a while it's something I'll look into more in creating a script during some downtime. At least I know it's possible (In Theory!)