Not sure about the first part. Do you mean it ends up in the JSS with quote marks? If thats the case it might be a quirk with the jamf script, in which case you might need to create your own.
The second problem can be handled with sed. Something like:
sed -i -- 's/CPSD-//g' /usr/local/bin/MBAnames.csv
-username MacAdmin -password Appleloosa8
I hope that's not a real domain admin account you just posted.
I will try that out. And no, that is a made up username and password. But I will remove the script with my domain name just for good measure
Not sure if this would be of any use, I work in a school environment, and we are at times loaded to the brim with work needing to be done. I wrote this script to rely on the NetBIOSName, which our AD controls NetBIOSName after it's been assigned from imaging. It simply reads the name and then uses it to name the computer using scutil.
#!/bin/sh
#Records name to be set for scutil from NetBIOSName
defaults=$(defaults read /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName)
#Sets the scutil names, please note the --get sometimes does not report correctly.
#This is due to scutil not reading the information correctly intermittently after changing it.
#If you are unsure, you can manually run the --get commands accordingly.
scutil --set HostName $defaults
scutil --get HostName
scutil --set ComputerName $defaults
scutil --get ComputerName
scutil --set LocalHostName $defaults
scutil --get LocalHostName
As for our asset tags, this pulls the same NetBIOSName and uses jamf's own asset command to update the information in Casper.
#!/bin/sh
asset=$(defaults read /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName)
jamf recon -verbose -assetTag "$asset"
For our asset field, we use the last 8 characters of the mac's name... We also hide the asset name in var/db...
#!/bin/sh
#1st get computer name#
COMPNAME=`/usr/sbin/scutil --get ComputerName`
#1a-hidecomputername on system#
touch /var/db/assetnumber
echo $COMPNAME > /var/db/assetnumber
#2-grab the last 8 characters#
vasset=${COMPNAME:(-8)}
#3-set the asset in Casper#
jamf recon -skipApps -skipFonts -skipPlugins -assetTag $vasset
This allows us to change a computer's name back if the user changes it by doing a name comparison and placing the variable if they are not equal....