I have a policy that runs at Enrollment Complete for DEP enrolled machines. The policy contains a .pkg with a postinstall script that prompts the tech for a computer name and then names the machine using scutil --set ComputerName, HostName and LocalHostname. I've also tried adding jamf -setComputerName and networksetup -setcomputername to the script. After the script runs I check all of those locations via terminal and all return the new, correct name.
The policy also includes a JAMF Directory Binding for Active Directory. When this policy runs it binds the machine to AD using the previous computer name.
My question is: Where does the JAMF Directory Binding task pull the computerID info from for the bind?
According to the logs, the Name Change is the first thing to happen (as it should because I've given it a priority of 2), then other software is installed, scripts are run, and then the AD bind happens at the end. The terminal checks that I've done were while the additional software was being installed, after the name change and before the bind.
I was just working on this earlier this week.
So it turns out that the JAMF Directory Bind takes the hostname at the START of the policy execution as the name to bind it with.
I ended up making two policies to solve this:
1) Runs the Computer name prompt/change script then calls a jamf policy custom trigger to a policy
2) Sets to execute at the custom event to perform the binding.