HI there,
We've been using a script to set the computer name on devices in the format of 'fullname-model'. This script has been working fine up until Sonoma where it breaks by not providing the full name variable. The only script that seems to work at the moment is one that pulls the username instead but this is not ideal for our environment due to some historic devices having usernames completely unrelated to the user.
Is anyone using a script that is able to pull full name from a source that works on Monterey, Ventura and Sonoma in the 'fullName-model' format?
This is what we have now
#!/bin/bash
userName=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')
echo $userName
model=$(system_profiler SPHardwareDataType | grep "Model Name:" | sed 's/.*://' | tr -d " \\t\\n\\r")
echo $model
serialNumber=$(system_profiler SPHardwareDataType | awk '/Serial/ {print $4}')
echo $serialNumber
name=$userName-$model-$serialNumber
echo $name
scutil --set HostName "${name}"
scutil --set LocalHostName "${name}"
scutil --set ComputerName "${name}"