Allow users to change the computer name

tristan
New Contributor

I use Casper Imaging 9.73 to image computers.

If I try to change the computer name on an imaged computer under System Preferences > Sharing > Computer Name, the computer name reverts back to the name that was set when the computer was imaged.

Is there a way to restore access to allow users to change the computer name under System Preferences > Sharing > Computer Name?

4 REPLIES 4

SeanA
Contributor III

db8300634a8045f5898089a21c4ea8eb
If you have "Reset Computer Names" checked in one of your JSS policies, then uncheck it. That would be my first guess. The option is located in the "Maintenance" section of the policy.

tvagle
New Contributor II

We have seen times where the first attempt at renaming doesn't stick
After a restart and 2nd or 3rd attempt...name change finally sticks

tristan
New Contributor

Hey SeanA and tvagle, thanks for the suggestions.

I currently do not have a policy that has the Maintenance section under the Options tab.

I also tried changing the computer name more than 3 times, but the name never sticks.

Are there any other suggestions?

Thanks.

dan-snelson
Valued Contributor II

We're using the following script as part of a Self Service policy scoped to our TSRs (which works in 9.73 and will need to be updated for 9.81)

#!/bin/sh
####################################################################################################
#
# ABOUT
#
#   Rename Computer
#
####################################################################################################
#
# HISTORY
#
#   Version 1.0, 18-Jun-2015, Dan K. Snelson
#
# Import logging functions
source /path/to/logging/script/goes/here
####################################################################################################

/bin/echo "`now` *** Rename Computer ***" >> $logFile

### Log current computer name
currentComputerName=`/usr/sbin/scutil --get ComputerName`
/bin/echo "`now` Current Computer Name: $currentComputerName" >> $logFile


### Prompt for new computer name
newComputerName="$(/usr/bin/osascript -e 'Tell application "System Events" to display dialog "Enter the new computer name:" default answer "" buttons {"Rename","Cancel"} default button 2' -e 'text returned of result' 2>/dev/null)"
if [ $? -ne 0 ]; then
    # The user pressed Cancel
    exit 1 # exit with an error status
elif [ -z "$newComputerName" ]; then
    # The user left the computer name blank
    /usr/bin/osascript -e 'Tell application "System Events" to display alert "No computer name entered; cancelling." as critical'
    exit 1 # exit with an error status
fi


### Set and log new computer name
/usr/sbin/scutil --set ComputerName "$newComputerName"
/bin/echo "`now` New Computer Name: $newComputerName" >> $logFile

### Update the JSS
/usr/sbin/jamf recon

# Inform user of computer renamed
/usr/sbin/jamf displayMessage -message "Renamed computer from: "$currentComputerName" to "$newComputerName""


exit 0      ## Success
exit 1      ## Failure