Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
changes the computer/host name in all relevant entries of the scutil
#!/usr/bin/env bash
function main() {
validate "$@"
set_name "$@"
if [[ "$2" == '-p' ]]; then
update_policy
fi
}
function validate() {
if [[ -z $1 ]]; then
usage
exit 1
fi
}
function set_name() {
local name="$1"
sudo scutil --set ComputerName "$name" && \
sudo scutil --set HostName "$name" && \
sudo scutil --set LocalHostName "$name" && \
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$name"
}
function update_policy() {
sudo jamf recon
sudo jamf policy
}
function usage() {
echo "
usage: ./compname.sh <name> [-p]
this command changes the computer/host name in all relevant entries of the scutil (ComputerName, HostName and LocalHostName).
pass a new name for the computer as the first argument. use the -p option to also update the jamf policy accordingly.
"
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.