Rename mac for catalina

WBS
New Contributor III

Looking for a way to prompt in self service to rename a mac. I had a script that worked in mojave but now it doesn't in catalina. Anybody know of one that will work in self service?

4 REPLIES 4

petedogg
New Contributor II

This is what I use:

!/bin/bash
Script to prompt for ComputerName, Set Name and Inventory in JAMF
assetTag=$(osascript -e 'text returned of (display dialog "Please type in the Asset Tag Number: "default answer "Enter Number Here" buttons {"Submit"} default button 1)')
computerName=$assetTag

Set Computer Name
scutil --set HostName $computerName
scutil --set LocalHostName $computerName
scutil --set ComputerName $computerName

Run Recon
jamf recon -assetTag $assetTag

Knoxx
New Contributor II

At our company we prefix with MB +Serial Number for computer name

SERIAL_NUMBER=ioreg -l | grep IOPlatformSerialNumber|awk '{print $4}' | cut -d " -f 2

COMPUTERNAME=MB$SERIAL_NUMBER
echo "Setting computer name to $COMPUTERNAME"
/usr/sbin/scutil --set ComputerName "$COMPUTERNAME"
/usr/sbin/scutil --set LocalHostName "$COMPUTERNAME"
/usr/sbin/scutil --set HostName "$COMPUTERNAME"
dscacheutil -flushcache
/usr/local/bin/jamf recon
exit 0

Works like a charm

kalmedani
New Contributor

In Our Company we use this Command to rename Computer

jamf setComputerName -useSerialNumber -prefix "NB"

benbass
New Contributor III

@Knoxx Simply because I am not a fan of using grep and awk one after another when awk can do all the things easily. You can even have it add the prefix if you are not using SERIAL_NUMBER for anything else.

COMPUTER_NAME="$(ioreg -l | awk -F'"' '/IOPlatformSerialNumber/ { print "MB"$4; exit; }')"