Computer name updates in inventory

tnielsen
Valued Contributor

Hi all, it's brainfart Thursday here and I'm having trouble figuring out if the computer name should be updated in the JSS, if it's been changed at the computer, during an inventory scan.

Thanks.

13 REPLIES 13

mm2270
Legendary Contributor III

You mean, if you go into System Preferences > Sharing and change the Computer Name, should it then update in the JSS for that record after a recon? If so, then yes, it should. I don't know exactly where the jamf binary gets the information from, but whether its from scutil, system_profiler, or some other tool, the name it pulls should reflect what the name is in that field in the Sharing preference pane.
Even if you change the name using a script, as long as the inventory collection takes place after the script runs (which it would) it should still update.

strider_knh
Contributor II

An inventory is not required. When a station does its standard check-in then the name in the JSS will update to match the device name. An inventory update after the script just makes sure you have the latest info and is a good idea.

Chris_Hafner
Valued Contributor II

*UNLESS you have "Reset Computer Name" checked in a policy somewhere. I have that running as part of my daily inventory. This resets the computers "Computer Name" from the JSS record. I only bring it up because I've seen people forget about this check box in a policy somewhere.

ernstcs
Contributor III

@strider.knh, to my knowledge a simple check-in does not update all of the inventory information, just the IP address and whatever other triggers you have setup for policies.

The computer name in inventory debate has gone on for a long time and to this day I still don't think there is an option in the JSS to always force a machine name to what it was originally entered in as in the JSS. Perhaps this has changed. But invariably what happens is someone changes the machine name or it gets the (<number>) added to the end of it and then a recon cycle runs and updates it to the new name in the JSS. Later you go to use the Reset Computer Names option in a policy or remote session and now it's just renaming it to the same junk name it had in its record.

Many places don't want the machine name to change ever, even by the user. During our imaging process we actually run a script at reboot that creates a separate name file tucked away on the computer that we can reference as the original name during imaging. So if we really want to make sure inventory is correct in terms of name we first call this computer name file with a script and reset the computer name back from it first and then run a full jamf recon inventory on it. This also should remove any of the strange (<number>) names that happen or whatever else the user has done.

stevewood
Honored Contributor II
Honored Contributor II

Actually @ernstcs, @Chris_Hafner is correct, there is an option on a policy to enforce the name at check in. On the Maintenance Tab of any policy there is the option "Reset Computer Names" which does the following:

Change the computer name on computers to match the computer name in the JSS

So if you are trying to keep the names set to what is in the JSS, that is how you do it.

What does not happen is that the name will not update in the JSS if it is changed on the machine and only a recurring check-in is done (or jamf policy from terminal). A full recon does need to take place in order for the name to change in the JSS.

If you want to keep the name the same as in the JSS, you can set a policy that does that and is set to Recurring Check-In with an Execution Frequencey of Ongoing. That WILL fix the name at each check-in (jamf policy).

ernstcs
Contributor III

Certainly @stevewood, I was not contending what @Chris_Hafner stated on this. That option has been around...well...forever! Kind of like us.

Even with the options that exist though there is still no 100% absolute way of maintaining name by the JSS, in my opinion. Your suggestion is as close as you can get without JAMF actually adding a setting in the JSS to not allow the machine name to deviate from what it was originally named at imaging or manually edited by an admin in the JSS.

Chris_Hafner
Valued Contributor II

Heh, I have to come in and agree with the both of you. It's not 100% compliant. I mean, that with the properly functioning policy enforcing computer names there is always a time in which a user can change a name, before it get's changed back to it's JSS records Computer Name. What can be more interesting is that I've seen "Computer Name" deviate form hostname and Computer host name. Sometimes I've had to script a naming policy to change all at the same time. Yet, it's been many versions since I've had to do that.

tnielsen
Valued Contributor

Thanks guys.

Just to be clear, if I have a policy that runs Daily at reoccuring check-in to update inventory on all macs.. then the computer name should update in the JSS if it was changed over 24 hours ago.

I allow the name to change in the JSS, fyi. There is an option to force the computer name change to match what the JSS has, but that is not enabled. (Although I'm starting to think this would be ideal in the future)

Chris_Hafner
Valued Contributor II

@tnielsen When you absolutely HAVE to get the name changed, I like to use ARD. Even if the user is offline ARD can save the task in its task manager and change it the instant it appears.

stevewood
Honored Contributor II
Honored Contributor II

@tnielsen yes, what you described is correct.

@ernstcs - ah yes, we have been around the JAMF block a few times. And of course I know you know that I know that.... What was I saying now? Hey, you kids, get off my lawn!

mm2270
Legendary Contributor III

Yeah, under the right conditions, if the stars align just so, the name in the JSS could still get updated to what it was renamed to first, and then the JSS won't know it should be set back to its original name when the rename policy runs, since it will be lost at that point. (Actually it might show up in one of the hardware or software history items, but not sure)

What I might do to make it more consistent is run a one time policy that captured the Computer name after its initially set, say for example, after imaging, and store that in a file or plist tucked away somewhere.
Then, have an Ongoing policy run on some trigger or just on check in that would run a script to locate the name in the file or plist, and compare it to the name the computer is currently set to. If it doesn't match, fix it, If it matches, just exit.
We should not in theory need to do that, but that seems to be the only reliable way to keep a machine name as it was intended.

yadin
Contributor

Not seeing JAMF ever update the record name properly.
On enrollment a policy runs that has a script that is set to run before all other actions. This script sets the name to match DNS. This works, at first login after setup of a fresh install (DEP) the name in Sharing is correct. This policy also does an inventory check and jamf recon for good measure. These claim to run.
The computer record in JAMF is always wrong, it's just a generic mac mini or macbook pro.
Not only is this a problem because we can't have records properly show names, then other bad things happen...

We have another policy that is set to change the name of a machine that is not named properly (smart group) to match the record. This is so we can manually set a name of a machine in JAMF if DNS was missing. So about 30 min after enrollment policy runs, this policy gets triggered because the record name is wrong. If JAMF was working correctly, this would not trigger as the computer name is right, but JAMF fails to know that so the computer name scopes to the wrong group. The result is JAMF changes the correct name on the machine to the generic name in the record, which is the exact opposite of what should be happening.

So far we can't find any info on making this work right. Despite threads like this that insist a recon or update should make the record reflect the machine name, that does not happen, and appears to be a serious bug. This is further frustration on top of the missing feature of being able to name prestage records like you can in Profile Manager. All told this is making automated deployment with AD binding impossible (which is already an unusable feature in prestage enrollment since names will never be right if you can't pre-name). JAMF needs to get on this, still looking for functional work arounds....

drodriguez
New Contributor

Here's a script that might help: #!/bin/bash

SerialNumber=$(system_profiler SPHardwareDataType | grep "Serial Number" | awk -F':' '{print $2}' | sed -e 's/^[ ]//' -e 's/[ ]$//')

Set the computer name using the jamf binary

/usr/local/bin/jamf setComputerName -target / -name "$SerialNumber"