Does anyone know a way to either pull just the first name or username field from a Jumpcloud instance into Jamf?
Jamf seems to be able to query userid, username email address and Fullname however I'm looking to try and modify the below script to pull just the first name or username and add it so the computer name will end up being:
XXXX-MBP-FirstName or username-SERIAL Number
My ideal preference would be to just pull the first name but that's not a stand alone field so I don't think it's possible to pull this info. See sample script below. This would run right after pre-stage which is currently set to not create a username other than admin. Has anyone had success doing this?
----
#!/bin/bash
# Get the logged in username
logged_in_user=$(/usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | /usr/bin/awk '/Name 😕😕 && ! /loginwindow/ {print $3}')
#get computer serial number
serialNumber=`system_profiler SPHardwareDataType | awk '/Serial/ {print $4}'`
# Create a string
comp_name="XXXX-MBP-${logged_in_user}-$serialNumber"
# Rename the Mac using the jamf command line tool
jamf SetComputername -name "$comp_name"
jamf recon
exit 0
