Hello,
First time posting here, just want to start by saying thank you to everyone for your contributions, I've scoured this forum for a long time.
My current issue that I haven't been able to find any solution for is dynamically renaming our Macbooks. The script I use currently is this:
#!/bin/sh
#gets current logged in user
getUser=$(ls -l /dev/console | awk '{ print $3 }')
#gets named
firstInitial=$(finger -s $getUser | head -2 | tail -n 1 | awk '{print tolower($2)}' | cut -c 1)
lastName=$(finger -s $getUser | head -2 | tail -n 1 | awk '{print tolower($3)}')
computerName=$firstInitial$lastName"-lt1"
#set all the name in all the places
scutil --set ComputerName "$computerName"
scutil --set LocalHostName "$computerName"
scutil --set HostName "$computerName"
#update Jamf
jamf recon
This works great, but the problem I have is that every laptop get's renamed with the LT1 tag. So when we replace a laptop for someone, we now have TWO LT1 laptops listed for that user in Jamf.
Is there some what I can modify my current script to be dynamic? Such as, it pulls data from Jamf, determines if there is already an lt1 listed for that user, and then changes it to lt2 instead?
If not, no worries, we'll just stick to manual intervention, but would love to have a way to automate this.
Thanks all!