I have this script to rename the mac to its serial number during the enrollment process.
ioreg -l | awk '/IOPlatformSerialNumber/ { print $4;}' | sed 's/"//g' | scutil --set HostName
ioreg -l | awk '/IOPlatformSerialNumber/ { print $4;}' | sed 's/"//g' | scutil --set LocalHostName
ioreg -l | awk '/IOPlatformSerialNumber/ { print $4;}' | sed 's/"//g' | scutil --set ComputerName
This script requires a restart to take effect. I have another policy that runs to bind the Mac to the AD but the Mac needs to be named its serial number in order for the AD binding policy to work. Restarting stops the remaining enrollment automation so is there a way to add anything to this script change the computer name without restarting the mac?
