Skip to content

Instantly share code, notes, and snippets.

@jacobsalmela
Created January 12, 2015 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jacobsalmela/226cd8c26f0460096047 to your computer and use it in GitHub Desktop.
Save jacobsalmela/226cd8c26f0460096047 to your computer and use it in GitHub Desktop.
Rename computers to prepend something
#!/bin/bash
# Get the entire computer name and save it in a variable
#existingName=$(hostname | cut -d'-' -f2-)
existingName=$(hostname)
# Set the computer name to Repurpose-"Existing computer name"
scutil --set LocalHostName "Repurpose-$existingName"
scutil --set ComputerName "Repurpose-$existingName"
scutil --set HostName "Repurpose-$existingName"
serialNum=$(ioreg -l | awk '/IOPlatformSerialNumber/ { split($0, line, "\""); printf("%s\n", line[4]); }')
# Set the NetBIOS name as the serial number
defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$serialNum"
# Update the JSS and change the building to "Recycled"
jamf recon -building Recycled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment