Posted on 01-13-2024 04:34 AM
i am starting to lose my mind a bit here.
I am attempting to rename a few PCs that didn't get renamed during enrollment to: firstName lastName - serialNumber
To my understanding, there is a policy setting under maintenance to "Reset Computer Name" that should allow me to fill in the Computer Name field in the Inventory and it'll update the computer's name upon checking in.
However, when I tried that on a test computer, instead it renamed the machine to "Macbook Air"
I see that there's a simple script that can be done:
jamf setComputerName
I can also add a switch to it, i.e.: jamf setComputerName -useSerialNumber
But I can't find any confirmation as to whether I can use multiple switches at once.
I would like to, ideally, know why the Reset Computer Name policy isn't working, but failing that I would like to be able to have a command that is basically: jamf setComputerName -useFullName " - " -useSerialNumber
Any help would be greatly appreciated.
Posted on 01-13-2024 09:48 PM
@orewa There isn't a "-useFullName" option for the setComputerName verb (at least with version 11.0.1 of the jamf binary) so I'm not sure where you found that option.
As for fixing the name for your computers that aren't set to your standard, does your enrollment process run a script to set names or is the name set manually? If there's a script run at enrollment I'd suggest extracting the portion that does the renaming and run that as a normalization policy. If you're manually eating I'd suggest writing a script to set firstName and last name variables so you can use the -prefix option in conjunction with the -useSerialNumber option to build the name with a "$firstName $lastName - " prefix.
Posted on 01-16-2024 10:43 AM
Here's a snippet of how do it in a script. Essentially you are using scuttle to set ComputerName, LocalHostName, and Host to whatever you want. In theory at this point a recon would update JAMF, but I just use the JAMF binary with the setComputerName variable and all is good. I do this early on in the build process so its easier to look up computers in JAMF.
# Set the Computer Name to the user-entered value
scutil --set ComputerName "${computerName}"
# Set the LocalHostName to `newLocalHostName`
scutil --set LocalHostName "${computerName}"
# Set the lHostName to `newLocalHostName`
scutil --set HostName "${computerName}"
# Set JAMF computer name
"$jamfBinary" setComputerName -name "${computerName}"
Posted on 01-18-2024 02:49 PM
@roiegat If you are using the jamf command setComputerName you don't need to use any of the scutil commands because it already sets the ComputerName, LocalHostName, and Hostname.
Posted on 01-23-2024 05:47 AM
True. But some other scripts we use rely on the scutil to get the ComputerName or HostName. So any time we modify the values we make sure to modify them everywhere.