Posted on 06-18-2020 01:56 PM
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?
Posted on 06-19-2020 09:06 AM
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
Posted on 06-19-2020 10:41 AM
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
Posted on 06-19-2020 02:20 PM
In Our Company we use this Command to rename Computer
jamf setComputerName -useSerialNumber -prefix "NB"
Posted on 06-20-2020 10:41 AM
@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; }')"