# Name the Machine in all areas the same - Start
# Get Serial Number
sSerialNumber=$(system_profiler SPHardwareDataType |grep "Serial Number (system)" |awk '{print $4}' | cut -d/ -f1)
echo $sSerialNumber
# Ask User if the computer is a laptop
printf "Is this a laptop, if yes type y or if no type n followed by [ENTER]:"
read sLaptop
#echo "$sLaptop provided"
case $sLaptop in
"y")
sMachineName="L$sSerialNumber"
;;
"n")
sMachineName="D$sSerialNumber"
;;
*)
sMachineName=$sSerialNumber
;;
esac
echo $sMachineName
sudo scutil --set HostName $sMachineName
sudo scutil --set ComputerName $sMachineName
sudo scutil --set LocalHostName $sMachineName
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $sMachineName
# Name the Machine in all areas the same - Stop
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.