Where in this script are you trying to grab the full name? I only see you getting the short username.
Also, I don't think it's wise to try to pull a full name as part of a computer name. There could be odd characters, spaces and other things in that which could cause some issues when using it as a host name. Just my $0.02 on the issue. I'd use something more computer/device specific for this. Why not just use the model and serial number like you already have and drop the user name?
After using the "userName" variable, this command will give you the full name of the user:
finger -s $userName | head -2 | tail -n 1 | /usr/bin/awk '{print $2,$3}'
This will result in FirstName LastName. If you want to remove the space between the first name and last name, you need to add a sed command to the end.
finger -s $userName | head -2 | tail -n 1 | /usr/bin/awk '{print $2,$3}' | sed 's/[[:blank:]]//g'
To make this a variable you could write something like:
fullName=$(finger -s $userName | head -2 | tail -n 1 | /usr/bin/awk '{print $2,$3}' | sed 's/[[:blank:]]//g')
echo $fullName
I tested all of this in Sonoma.
I'm not trying to be rude here but understand; Why would you want a naming scheme like that vs just Serial Number? Seems way more complex than required.
I'm not trying to be rude here but understand; Why would you want a naming scheme like that vs just Serial Number? Seems way more complex than required.
But complexity is so much more fun! I have actually taught myself a lot by taking on the challenge of solving problems posted in Jamf Nation. Personally, I would not name a Mac using the user's name since that could be a security problem on a public WiFi network. I wouldn't want my name being broadcast to others. That's one reason all of my own Apple devices use Star Trek names. My MacBook Pro has been called "Enterprise" for several years.
Where in this script are you trying to grab the full name? I only see you getting the short username.
Also, I don't think it's wise to try to pull a full name as part of a computer name. There could be odd characters, spaces and other things in that which could cause some issues when using it as a host name. Just my $0.02 on the issue. I'd use something more computer/device specific for this. Why not just use the model and serial number like you already have and drop the user name?
The username/fullname are the only identifying variables for the devices. In order for us to confirm a user just based on serial number we would either have to check our Asset Manager or directly navigate into serial numbers to see the local account associated with the devices.
We currently dont have 'User and location' populated since we use Okta I don't think it can be used to generate this data which would've allowed us to make use of S/N in the device name and create an advanced search filter looking at the User and location data. I may be wrong though.
The username/fullname are the only identifying variables for the devices. In order for us to confirm a user just based on serial number we would either have to check our Asset Manager or directly navigate into serial numbers to see the local account associated with the devices.
We currently dont have 'User and location' populated since we use Okta I don't think it can be used to generate this data which would've allowed us to make use of S/N in the device name and create an advanced search filter looking at the User and location data. I may be wrong though.
That’s what I was curious by if it was your reasoning.
If you go into your Settings in Jamf then Inventory Display, you can change what shows up in a computer search. If you go under the User and Location and select username. Now when you’re browsing your inventory by hitting the search button with the field blank then after it lists all your devices type in a name and boom!
(You must also be collecting username from Inventory Collection tab under settings)
This email and any files transmitted with it are confidential, proprietary and intended solely for the individual or entity to whom they are addressed. If you have received this email in error please delete it immediately.
That’s what I was curious by if it was your reasoning.
If you go into your Settings in Jamf then Inventory Display, you can change what shows up in a computer search. If you go under the User and Location and select username. Now when you’re browsing your inventory by hitting the search button with the field blank then after it lists all your devices type in a name and boom!
(You must also be collecting username from Inventory Collection tab under settings)
This email and any files transmitted with it are confidential, proprietary and intended solely for the individual or entity to whom they are addressed. If you have received this email in error please delete it immediately.Interesting. Up until just now I thought this data was pulled from and LDAP connector like from Google Workspace or Azure. Thanks for this feedback, I'll give it a go.
Just since nobody has brought it up:
fullName=$(id -F $username)
Just since nobody has brought it up:
fullName=$(id -F $username)
Well that works too! I didn't know that command.