We have been using a script to initiate in self service that asks for the name of the mac and to add asset tag info to jamf. It seems to have stopped working and not sure why exactly. The naming portion seems to work but it does not reflect in the Jamf inventory entry every time. Can someone have a look at this and tell me why or what changed to make it no longer work? It's been in use for 2 years with no issues.
#!/bin/bash
#defining the jamf binary
jamf=$(which jamf)
#asking the logged in user via apple script dialogue box for the asset tag on the machine
assetTag=$(/usr/bin/osascript <<-'__EOF__'
text returned of (display dialog "Please type in your 6 digit asset tag for this computer.(Inventory Decal)" default answer "######" buttons {"OK", "Cancel"} default button 1 with icon file "Applications:System Preferences.app:Contents:Resources:PrefApp.icns")
EOF
)
#asking the logged in user via apple script dialogue box for the name of the machine
PreFix=$(osascript <<'EOF'
text returned of (display dialog "Please type in your Computer name for this machine" default answer "" buttons {"OK", "Cancel"} default button 1)
EOF
)
# Set Hostname using variable created above
scutil --set HostName "$PreFix"
scutil --set LocalHostName "$PreFix"
scutil --set ComputerName "$PreFix"
#setting the compuer assettag in Jamf and the computer name in Jamf
"$jamf" recon -assetTag "$assetTag"
"$jamf" setComputerName -name "$PreFix"
exit 0