Posted on 08-11-2016 06:04 AM
I have a TSV that lists all the computer names I hope to set with their associated WiFi MAC Address setup like so:
Computer Name MAC Address
I am not sure how to script this but I am hoping to get the devices MAC address, find the correct name in the list, then set the Computer Name, Host Name, Local DNS name and the "Student" accounts long name as that value. (The current user is "Student" located at /Users/student. I don't want to change it's short name or location, just the "Full Name")
Does anyone know how best to do this? It may have to be built as a package then pushed out. I do know it will need to look something like this and then add the user account section.
#!/bin/sh ## # Will set ComputerName LocalHost and DNS Name, macaddressnames.txt must be Unicode/Unix(LF) ## . /etc/rc.common ConsoleMessage "Setting Computer Name" #Define where the macaddressnames text file will be located. macadnames="/Library/renamer/macaddressnames.txt" #Execute if the macaddressnames file exists if [ -e $macadnames ]; then #Get WIFI Mac address myairportid=`/sbin/ifconfig en0 | grep -i ether | cut -f2 -d' ' | sed 's/://g'` #Search macaddressnames file for the WIFI Address and find the computer name mycname=`grep $macadnames -i -e$myairportid | cut -f2` #Search macaddressnames file for the WIFI Address and find the DNS name myrname=`grep $macadnames -i -e$myairportid | cut -f3` fi #Rename the Computer scutil --set ComputerName "$mycname" scutil --set LocalHostName $myrname scutil --set HostName $myrname dscacheutil -flushcache
Posted on 08-13-2016 04:51 PM
Have you considered using the serial number rather than the mac address? On the Windows side we've used mac addresses to name machines for years and when I recently began work on doing the same on the Mac side, I realized that serial numbers make much more sense since we have devices that only have wired interfaces and some that only have wireless. If interested, I can dig up the script I was working on for this. I pretty much had it working but wanted to do some more testing. Other projects have delayed this. I don't have it available at the moment but could post it Monday or Tuesday.
Sorry, I can't help you on the account name change since we use AD accounts.
Posted on 08-25-2016 07:35 PM
Remember that when generating the computer name, it is best to not use the student's real name. The computer name is broadcast in the clear via WiFi and could be used for nefarious purposes.
Student names can be used in ARD custom fields as those values are encrypted in transport between the client and ARD admin console.