Skip to main content
Question

Creating an account via script


Forum|alt.badge.img+10

Hi all

I want to create an account within the Macbook using JAMF policy > Script.

I've searched online some info, updated it with $4, $5, etc so that it fits JAMF Pro. But when I ran it, nothing happens.

Anyone got any suggestions?

#!/bin/bash username=$4 password=$5 adminRights=$6 dscl . -create /Users/$username dscl . -create /Users/$username UserShell /bin/bash dscl . -create /Users/$username RealName $username dscl . -create /Users/$username UniqueID "999" dscl . -create /Users/$username PrimaryGroupID 20 dscl . -create /Users/$username NFSHomeDirectory /Users/$username dscl . -passwd /Users/$username $password if [ "$adminRights" = "admin" ]; then dscl . -append /Groups/admin GroupMembership $username fi

6 replies

Forum|alt.badge.img+10
  • Author
  • Valued Contributor
  • 143 replies
  • October 19, 2018

Belay that....
The account has been created :)
It's just that it didn't create a home directory. But I did find the account within System Preferences > Users.

I think I'm good now.


Forum|alt.badge.img+5
  • Contributor
  • 96 replies
  • October 19, 2018

Just to let you know hat DSCL is restricted under 10.14 so you may have some problems using that script


Forum|alt.badge.img+15
  • Valued Contributor
  • 301 replies
  • October 19, 2018

I recommend using sysadminctl in High Sierra and Mojave, otherwise you'll run into issues with secureToken and enabling FileVault. dscl also seems to strip secureToken from users that already have it if using that command to reset the user's password in the future.

sudo sysadminctl -adminUser AdminUserHere -adminPassword AdminPasswordHere -addUser NewUserNameHere -fullName "Full Name Here" -password NewUserPasswordHere -admin

It auto sets the shell and UID, but you can specify those with additional flags. Check out sysadminctl --usage There's a password passthrough option - as well.


Forum|alt.badge.img+5
  • Contributor
  • 30 replies
  • October 19, 2018

why don't you use the function in the jamf binary it can create an account on the local machine


Forum|alt.badge.img+5
  • Contributor
  • 96 replies
  • October 19, 2018

It not very flexible and sometimes fails on new OS versions until Jamf fix it.

Use Greg Negale’s python script if you want to make users. It does direct Directory Service calls


Forum|alt.badge.img+26
  • Honored Contributor
  • 457 replies
  • October 19, 2018

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings