JAMF computer name change won't stick

Duke78
New Contributor III

I am trying to change a computer's name by editing it in the computer's Jamf Pro inventory > General page. I have a policy to change all of my managed computers' names to match the names set in Jamf, so theoretically this name change should be pushed out to the machine after I updated it in Jamf. This is an iMac running MacOS14.4.1. But when I change the name on this machine and save it, the page reverts back to the default "iMac" name. I've done this hundreds of times and have never had an issue getting a name change to stick in the Jamf Pro inventory. Has anyone else seen this issue? 

1 ACCEPTED SOLUTION

mojo21221
Contributor II

I believe there is a bug in the jss that jamf currently working on cant think of the PI at the moment. But file a ticket with support and let them know you are suffering. 

View solution in original post

7 REPLIES 7

AJPinto
Honored Contributor II

On macOS the hostname is set in 3 areas. I have never had any luck using the computers record to actually set a hostname, so I use a script with a policy to run on devices that the hostname does not meet our standards. Below is the script I use, granted we just set the hostname to the serial number. You could adjust the variable to call a value from Jamf to meet your needs if this is helpful.

 

#!/usr/bin/env bash
#*=============================================================================
#* Script Name: Configuration: Set Hostname 2301
#* Created: [01.12.2023]
#* Author: Anthony Pinto
#*=============================================================================
#* Purpose: Requests input and renames computer based on Naming Convention 2301
#*=============================================================================

#*=============================================================================
#* REVISION HISTORY
#*=============================================================================
#* Date: [01.12.2023]
#* Author: Anthony Pinto
#* Issue: First version of this script
#* Solution: N/A
#*=============================================================================


#*=============================================================================
#* GLOBAL VARIABLES
#*=============================================================================
DIV1='echo ####################################################################'
DIV2='echo --------------------------------------------------------------------'
DIV3='echo ....................................................................'
ActiveUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }' | tr "[a-z]" "[A-Z]"`
ActiveUserRealName=`dscl . -read /Users/$ActiveUser | grep RealName: | cut -c11-`
    if [[ -z $ActiveUserRealName ]]; then
        ActiveUserRealName=`dscl . -read /Users/$ActiveUser | awk '/^RealName:/,/^RecordName:/' | sed -n 2p | cut -c 2-`
    fi
computerName=$(scutil --get ComputerName)
hostName=$(scutil --get HostName)
localHost=$(scutil --get LocalHostName)
serialNumber=$(system_profiler SPHardwareDataType | awk '/Serial/ {print $4}')
serialNumberII=$(system_profiler SPHardwareDataType | awk '/Serial/ {print $4}' | tr -d '"')
#*=============================================================================
#* FUNCTIONS
#*=============================================================================
userInfo () {
    echo; $DIV1
    echo "User Information:"
    if [[ "$ActiveUserRealName" == "$ActiveUser" ]]; then
        echo  "$ActiveUserRealName (Local Admin)"
    else 
        echo "$ActiveUserRealName ($ActiveUser)"
    fi
    $DIV1
}
#*=============================================================================
#* SCRIPT BODY
#*=============================================================================
userInfo

## Check & Update Computer Name
if [ "$computerName" == "$serialNumber" ]
then
	echo "Computer name matches serial number, $serialNumber"
else
	echo "Current Computer Name: $computerName"
	echo "Computer Name does not meet standards"
	echo "Changing Computer Name to match Serial Number"
	scutil --set ComputerName "$serialNumber"	
fi; $DIV2

## Check & Update Host Name
if [ "$hostName" == "$serialNumber" ]
then
	echo "Host Name matches serial number, $serialNumber"
else
	echo "Current Host Name: $hostName"
	echo "Host Name does not meet standards"
	echo "Changing Host Name to match Serial Number"
	scutil --set HostName "$serialNumber"
	
fi; $DIV2


## Check & Update Local Host
if [ "$localHost" == "$serialNumber" ]
then
	echo "Local Host matches serial number, $serialNumber"
else
	echo "Current Local Host: $localHost"
	echo "Local Host does not meet standards"
	echo "Changing Local Host to match Serial Number"
	scutil --set LocalHostName "$serialNumber"
	
fi; $DIV2


## Final Check
computerNameII=$(scutil --get ComputerName)
hostNameII=$(scutil --get HostName)
localHostII=$(scutil --get LocalHostName)

echo ""
echo "Serial number: $serialNumber"
echo "Computer Name: $computerNameII"
echo "Host Name: $hostNameII"
echo "Local Host: $localHostII"
if [[ "$computerNameII" == "$serialNumber" ]] && [[ "$hostNameII" == "$serialNumber" ]] && [[ "$localHostII" == "$serialNumber" ]] 
then 
	echo "Computer Name satisfies naming standards"
	$DIV1; exit 0
else
	echo "Computer does not meet naming standards"
	echo "More troubleshooting will be necessary."
    $DIV1; exit 1
fi 

## Perform final Recon to update computer name on Jamf
sudo jamf recon
#*=============================================================================
#* END OF SCRIPT
#*=============================================================================

 

mojo21221
Contributor II

I believe there is a bug in the jss that jamf currently working on cant think of the PI at the moment. But file a ticket with support and let them know you are suffering. 

Duke78
New Contributor III

I filed a ticket and this solved it, thanks!

DefNotOriginal
New Contributor

Check the iMac topic ID and your Jamf Server topic ID. I would start there, if they don't match it then no change will be pushed to the endpoint.

Jamf support suggested renaming them using MUT or scripting and pushing policy, unfortunately they keep getting renamed back to it's original default name.

DavidSpribe
New Contributor II

This problem is still not solved. Only the people with Group Access (Admin) privileges have the problem with renaming computers in the inventory list. Full Access admins do not have such problem

jclark27
New Contributor III

Hey Just wanted to add another person to this list, I have also already created a ticket for this.

It also affects certain ext attributes in the general section. We can't add  data in any ext attribute that has text entry as an option. (we use one for quick notes for example)

Workaround is to move the attribute to a different inventory section instead of general, but obviously we can still not rename the computers.

BM-Degenkamp
New Contributor III

I am having the same issue. Manually changed a couple of names in Jamf, but with no result. I would love to see this fixed.