Mac Rename Script
Here at the “Mothership” we had a big problem. Apple Mac computers were not named in a coherent way, that and some of our users didn’t like having an intangible name on their macs, so they would go and named the macs after their dogs and cats.
So I wrote a Mac Rename Script that checks what type of computer you have, if you have a laptop it ads the prefix ML- for Mac Laptop and if you have a Workstation (Mac Mini, iMac or Mac Pro) it ads MW- then after the model is chosen, it attaches the serial number of the mac to the name like this: ML-C1M23RM0236T6
In order to make the users unable to change the name I attach it to the login hook, that way if I see a computer named differently I can reboot the Mac in question and it will be renamed accordingly.
Continue reading after the break for the full script and the code needed to inject it into the Login Hook.
If you wish to inject the script in the Login hook, so its executed every time the computer boots simply open Terminal and type the following: sudo defaults write com.apple.loginwindow LoginHook /path/to/script so for example if your file is stored in /Users/Shared/Your.Company/scripts/macrenamer.sh then your line should look like this:
sudo defaults write com.apple.loginwindow LoginHook /Users/Shared/Your.Company/scripts/macrenamer.sh
You could also invoke a ./Users/Shared/Your.Company/scripts/macrenamer.sh command from ARD, if you wish to activate it.
Remember when you save your file to use the extension .sh