Skip to content

Instantly share code, notes, and snippets.

Created July 28, 2015 15:38
Show Gist options
  • Save anonymous/622da1f6660325a6c766 to your computer and use it in GitHub Desktop.
Save anonymous/622da1f6660325a6c766 to your computer and use it in GitHub Desktop.
#!/bin/sh
# get machine serial number
MAC_SERIAL_NUMBER=`ioreg -l | grep IOPlatformSerialNumber|awk '{print $4}' | cut -d \" -f 2`
# echo the value prefixed by "RuntimeSetBindingComputerID:" to make it compatible with the directory binding tasks
echo "RuntimeSetBindingComputerID: ${MAC_SERIAL_NUMBER}"
systemsetup -setcomputername ${MAC_SERIAL_NUMBER}
/usr/sbin/scutil --set LocalHostName ${MAC_SERIAL_NUMBER}
/usr/sbin/scutil --set HostName ${MAC_SERIAL_NUMBER}
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment