Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
Last active September 5, 2019 17:54
Show Gist options
  • Select an option

  • Save talkingmoose/5d0ca5f32dfa3532dc5eea6d5d25cb76 to your computer and use it in GitHub Desktop.

Select an option

Save talkingmoose/5d0ca5f32dfa3532dc5eea6d5d25cb76 to your computer and use it in GitHub Desktop.
Renames Computer Name, Local Host Name and Host Name to serial number.
#!/bin/sh
# read serial number
serialNumber=$( /usr/sbin/system_profiler SPHardwareDataType | /usr/bin/grep "Serial Number" | /usr/bin/awk -F: '{ print $2 }' | /usr/bin/xargs )
# set the three computer names
/usr/sbin/scutil --set ComputerName "$serialNumber"
/usr/sbin/scutil --set HostName "$serialNumber"
/usr/sbin/scutil --set LocalHostName "$serialNumber"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment