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