I currently have an enrollment workflow similar to what you are describing. This works well for us on macOS 12.5 (even tested with macOS 13). See below.
- Create a package copying the kcpassword file to /private/etc (file ownership should be root:wheel and permissions 600)
- You can generate this file by setting auto login on for the user in System Preferences on a test device, then grabbing a copy of the kcpassword file from /private/etc
- Create postinstall script for package
- Script should contain the following code:
- if [ -f /etc/kcpassword ]
then
/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser <auto_login_username_here_remove_brackets>
fi
- I'm enabling ssh, kickstarting ARD as well as setting the user photo as well which are all optional
I have a policy that installs the "Deploy_Autologin.pkg" package as an Enrollment complete trigger. My Enrollment policies are prepended with numbers 01-xxx to ensure they are executed in the order I want/need. The final policy with the enrollment complete trigger is a "Reboot" policy. After reboot, our auto login account is then auto-logged in and the configuration phase begins, one of the policies deletes the kcpassword file and deletes the autoLoginUser key from the com.apple.loginwindow plist which disables auto-login. During the configuration, right before the final reboot policy, I create a dummy file that an extension attribute is looking for. if the dummy file exists (EA = TRUE) the device is added to a Smart Group that is scoped to delete the enrollment account at at all of the necessary triggers. Long story short, yes I've done this and yes this works (for me at least). Hopefully this helps.