Hi all,
I just migrated from JamfNow to JamfPro and Im very new here.
Im addressing computer's name by a Smart Group with a policy to execute this Script, which is not working for me.
Basically I want to use the prefix MBP or MBA, depending on the model, following the SN of the laptop.
Any advice or help will be highly value.
#!/bin/sh
# Get laptop model
model=$(system_profiler SPHardwareDataType | awk '/Model Identifier/ {print $3}')
# Get Serial Number
serial=$(system_profiler SPHardwareDataType | grep Serial | awk '{ print $4 }')
# Assign a prefix
if echo "$model" | grep -q "MacBookPro"; then
prefix="MBP"
elif echo "$model" | grep -q "MacBookAir"; then
prefix="MBA"
else
prefix="APPLE"
fi
# Generate computername
computerName="$prefix-$serial"
echo "$computerName"
# Rename computer
scutil --set ComputerName "$computerName"
sleep 5
scutil --set HostName "$computerName"
sleep 5
scutil --set LocalHostName "$computerName"
sleep 5
echo "Computer renamed to $computerName"
# Clean caché and push an inventory sync
dscacheutil -flushcache
/usr/local/bin/jamf recon
Thanks a lot,