Posted on 12-11-2018 06:05 PM
I've been told many times I'm going about this the wrong way, but I really want a simple solution that doesn't require a bunch of scripts, so....
We have all our devices in DEP. They are set to a prestage enrollment that has the directory settings set to Bind to AD and set the Client ID to LTM-$USERNAME at enrollment. This works fantastic. Machine starts up, goes to the management screen which requires authentication, user authenticates, machine is bound to AD with the correct name and shows in both Directory Utility as well as AD with the correct name.
The problem is, for whatever reason, this doesn't set the Computer Name to be that. The Machine shows up in JAMF as MacBook Air. A quick check of scutil shows the computer name, host name, and local host name are all MacBook Air.
So, assuming this isn't a bug or is "working as designed" which it really should be setting those all to the same thing at the bind, how do you call out the Client ID to write a script to set the Computer Name to be the same after it is bound?
Posted on 12-12-2018 01:36 AM
We use this as the first policy that runs once the computer is enrolled. The computer still enrolls into jamf as MacBook Pro etc., but this then changes the name. We follow this up with a recon command. It seems to work. We use the serial number, so I assume amendingthe script for your naming convention should work.
#!/bin/sh
#First, get the computer name
COMPUTERNAME=`scutil --get ComputerName`
echo "$COMPUTERNAME"
#Second, get the Serial Number
SERIALNUMBER=`system_profiler SPHardwareDataType | awk '/Serial/ {print $4}'`
echo "$SERIALNUMBER"
if [ "$COMPUTERNAME" == "$SERIALNUMBER" ]; then
echo "no change"
else
/usr/local/jamf/bin/jamf setComputerName -useSerialNumber
fi