AD Bind during imaging in relation to scripts set to "After"


We're working on streamlining even more of our modular imaging process so I'm working on a script that will create the AD user's account and home directory during the imaging process. Thanks to folks on JAMF Nation and other sites we've been able to piece together the following script:


## $4 represents the parameter you plug in under the scripts field of a policy or in Casper Imaging

sudo ditto /System/Library/User Template/English.lproj /Users/$4

sudo ditto /System/Library/User Template/Non_localized /Users/$4

sudo chown -R $4 /Users/$4

sudo /System/Library/CoreServices/ -n $4

sudo dscl . -append /Groups/admin GroupMembership $4

As a policy it works great, however as a script that's part of the FirstRun script when using Casper Imaging I think it's choking on the creatmobileaccount cmd. The only reason I can think that this would happen is due to the fact that the machine is not part of the domain yet.
28c121a0c75f4b79b8d6568ae9a868f4 My main question is does anyone know when the directory binding occurs in relation to the scripts that will run during the FirstRun script? I'm thinking that it would happen after domain join occurs during the "Aquent AD" part but I don't know for sure.

Any help would be appreciated!


Valued Contributor II

The order would be Active Directory Bind, Numerical Script Names and then Alphabetical Script names.