OSX El Capitan - Script that adds Domain admin user not working anymore

So, my colleague made a script couple years ago that showed an input window where you could write the username and it would then add that user as domain admin user in users and groups. The script looked like this:

tell application "Finder"
activate
set user_name_dialog to display dialog “Enter end user account name:” default answer “” buttons {“OK”,“Cancel”} default button "OK"
end tell
set user_name to text returned of user_name_dialog
do shell script "/System/Library/CoreServices/ManagedClient.app/Contents/Resources/createmobileaccount -n " & user_name & space & “-v” with administrator privileges
do shell script “dseditgroup -o edit -a " & user_name & " -t user admin” with administrator privileges

Seems that the script is no longer working and I assume the reason being the tightened security in El Capitan (root account got smashed). The script runs fine from Bigfix but the user cannot install anything even thou Users and Groups says he/she has administrator privileges. This is fixed if I delete the user and we manually create the user again.

I don’t have much experience in Applescript so I’m kinda stuck for the moment. Any ideas? Should I even user applescript or try something completely different?

The applescript looks fine, but I don’t have a lot of experience creating mobile accounts so I could be wrong. El Capitan seems to support that command still.

You could try this command in place of the dseditgroup:
dscl . -append /Groups/admin GroupMembership user_name

I would also say a reboot is good practice once adding a user to the admin group.

I tried:

do shell script “dscl . -append /Groups/admin GroupMembership user_name” with administrator privileges

User is added but does not have admin credentials.

I think you’d want to use:
do shell script "dscl . -append /Groups/admin GroupMembership " & user_name with administrator privileges

1 Like

It works. Thank you for the help!