Hi All,
This one has come up before in the forums, but I am trying to determine why my script has stopped working in my test environment but still is working fine in production. It's the same script and I made sure to change the script to reflect the API user in test. We have a field in our preload called AssetTag which the script should be reading and then renaming the device to based on serial. This script is failing with the following error: Asset Tag is being set in the preload and is being seen by JAMF on the record but is not completing the change.
Script exit code: 1
Script result: Asset Tag is empty. Exiting...
Error running script: return code was 1.
/bin/bash
#set the variables for the server and API account
jssUser=APIUSER
jssPass=PASSWORD
jssHost=https://jamfcloudinfohere.jamfcloud.com
#get the serial number
serialNumber="$(ioreg -l | grep IOPlatformSerialNumber | sed -e 's/.*\\"\\(.*\\)\\"/\\1/')"
#get the asset tag from jamf
assetTag=$(/usr/bin/curl -H "Accept: text/xml" -sfku "${jssUser}:${jssPass}" "${jssHost}/JSSResource/computers/serialnumber/${serialNumber}/subset/general" | xmllint --format - 2>/dev/null | awk -F'>|<' '/<asset_tag>/{print $3}')
# set computer name
if [ "$assetTag" == "" ]; then
echo "Asset Tag is empty. Exiting..."
exit 1
else
/usr/sbin/scutil --set HostName "$assetTag"
/usr/sbin/scutil --set LocalHostName "$assetTag"
/usr/sbin/scutil --set ComputerName "$assetTag"
fi
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName "$assetTag"
/usr/local/jamf/bin/jamf recon
Thanks for any suggestions!