One of my remote clients has a Mac admin onsite whose job it is to enroll new or refreshed Macs into Jamf Pro, and to provide some of the end user support when needed. I want to simplify his job, and also ensure that proper naming is performed during enrollment. I have already deployed a script that will run right after enrollment that will prompt him to name the Mac. After that, the policy runs a recon to ensure that the new name is immediately submitted into the Mac's machine record. Since users are often still using the Mac that the new one is replacing, I want to setup a policy in Self Service that he can use to rename the existing Mac, and append "OLD" to the end of the name. I'm sure that the solution to this is to use basically the same commands, but I don't know how to add a line that adds "OLD" to the end of the Mac's name. I don't want the existing Mac to be completely renamed. I just want "OLD" to be added to the end. Something like "Mike-Smith-OLD". How do I make this happen?
The commands that my enrollment script runs are:
/usr/sbin/scutil --set ComputerName "${computerName}"
/usr/sbin/scutil --set LocalHostName "${computerName}"
/usr/sbin/scutil --set HostName "${computerName}"
During enrollment, I have the script setup so that the admin is prompted to give the Mac a name.
#!/bin/sh
computerName=$(osascript -e 'tell application "SystemUIServer"
set myComputerName to text returned of (display dialog "Please give this Mac a name then click Submit." default answer "" with title "Asset ID" buttons {"Submit"} with icon caution)
end tell')
/usr/sbin/scutil --set ComputerName "${computerName}"
/usr/sbin/scutil --set LocalHostName "${computerName}"
/usr/sbin/scutil --set HostName "${computerName}"
dscacheutil -flushcache
echo "Computer name has been set..."
echo "<result>`scutil --get ComputerName`</result>"
exit 0