Unable to login after creating admin user using bash script
the below script creates admin user and also changes the primary admin to standard as intended but when i try to login using admin user, (1)it gets stuck at the login windows after appending password. No File Vault enabled. (2) I am expecting the below script to enable secureTokenOn but when i checked from the Terminal it shows that it has not been enabled except the primary user.
please note: I am running this script remotely via Intune MDM.
#!/bin/bash
maxUID=$(sudo dscl . list /Users UniqueID | awk '$2>m{m=$2}END{print m}')
nextUID=$(($maxUID+1))
sudo dscl . create /Users/admin
sudo dscl . create /Users/admin UserShell /bin/bash
sudo dscl . create /Users/admin RealName "admin"
sudo dscl . create /Users/admin UniqueID $nextUID
sudo dscl . create /Users/admin PrimaryGroupID 1000
sudo dscl . create /Users/admin NFSHomeDirectory /Local/Users/admin
sudo dscl . passwd /Users/admin password
sudo dscl . append /Groups/admin GroupMembership admin
sudo cp -R /System/Library/User\ Template/English.lproj /Users/voloadm
sudo chown -R voloadm:staff /Users/admin
Out=$(sudo dscl . list /Users | egrep -v "^_" | egrep -w "admin")
sudo sysadminctl -secureTokenOn $Out -password pass
Output=$(sudo dscl . list /Users | egrep -v "^_" | egrep -vw "daemon|root|nobody|admin")
# loop on every user to change the account type to standard
for user in $Output ; do sudo dseditgroup -o edit -d $user admin ;done
it would be great if someone shed light on it.
Endgoal: enable secureTokenOn before file vault encryption & the admin user should be able to login.
Moreinfo, from intune I am not able to use sysadminctl but dscl works perfectly, therefore I am expecting the same if in case someone wants to correct it. it is going to be NON-Interactive.
MacBook Pro 13″, macOS 10.15