Skip to main content
Jamf Nation, hosted by Jamf, is a knowledgeable community of Apple-focused admins and Jamf users. If you like what you see, join us in person at the ninth annual Jamf Nation User Conference (JNUC) this October for three days of learning, laughter and IT love.

Renaming Computer Issues

I am using a simple AppleScript here to rename our computers before they get bound to AD. The computer name changes via the script, but as soon as it "Checks in" the names change back to MacBook Air. Occasionally it works fine and does not change back, but there is no rhyme or reason as to why. I have verified that NONE of my policies have the "Reset Computer Names " under the Maintenance Policy checked.

These are brand new machines never before logged in.

#!/bin/bash
ComputerName=`/usr/bin/osascript << EOT
tell application "System Events"
    activate 
    set ComputerName to text returned of (display dialog "Please Input New Computer Name" default answer "" with icon 2)
end tell
EOT`
#Set New Computer Name
echo $ComputerName
/usr/sbin/scutil --set ComputerName "$ComputerName"
/usr/sbin/scutil --set LocalHostName "$ComputerName"
/usr/sbin/scutil --set HostName "$ComputerName"
echo "Rename Successful"
dscacheutil -flushcache
jamf recon
exit 0
Like Comment
Order by:
SOLVED Posted: by ShaunRMiller83

I know you mentioned you checked your policies but do you happen to have a Login Window Config Profile?

In that Config Profile payload is an option to "Set Computer Name to Computer Record Name"

Also have a close look at your other Config Profiles as well. I have been bit a few times where JAMF deploys a config profile with a "hidden" unrelated setting and causes some havoc.

Like
SOLVED Posted: by ammonsc

I think you will need to change the computer name with the jamf binary command instead.

jamf setComputerName -name "$ComputerName"

Like
SOLVED Posted: by ammonsc

We use the following script

#!/bin/bash

NewComputerName="$(osascript -e 'Tell application "System Events" to display dialog "Enter the Asset ID Number:" default answer ""' -e 'text returned of result' 2>/dev/null)"

jamf setComputerName -name "$NewComputerName"

jamf recon -assetTag "$NewComputerName"
Like
SOLVED Posted: by arepko

We do have a Login Window Config Profile! Thought for sure it would be this! But... verified that it is Not checked as well.

Verified the rest of our Config profiles as well. None of them have any settings for the name.

Going to RE-double check all of the policies again.

Like
SOLVED Posted: by arepko

ammonsc - I'll give that a go and see if it holds any better for us.

Like

Jamf wants to know how you would organize content on Jamf Nation.