Is there a way to mimic a user login through terminal?

Script Example:

sudo dscl . -create /Users/ITAdmin
sudo dscl . -create /Users/ITAdmin UserShell /bin/bash
sudo dscl . -create /Users/ITAdmin RealName ITAdmin
sudo dscl . -create /Users/ITAdmin UniqueID 502
sudo dscl . -create /Users/ITAdmin PrimaryGroupID 20
sudo dscl . -create /Users/ITAdmin NFSHomeDirectory /Local/Users/ITAdmin
sudo dscl . -create /Users/ITAdmin NFSHomeDirectory /Users/[ITuser]
sudo dscl . -passwd /Users/ITAdmin [password]
sudo dscl . -append /Groups/admin GroupMembership ITAdmin

When using this locally or remotely, it works except the Home folder does not create or show up in the UI. After further testing, it does show up after an initial first time login. With our remote workforce and the secondary reasons for needing this script, we're trying to find a way to mimic a user login to add into our actual other script so that the home folder is created without actual end user interaction (won't be possible.)

Or are there any other alternative ways to script a new admin user account?

(Or a better place to ask this?)

Thanks in advanced!

Replies

Two things:

  • Apple Developer Forums is, as the name suggests, focused on development. You’re more likely to find answers to your sysadmin questions on Apple Support Communities, run by Apple Support.

  • In terms of manipulating user accounts, that’s not really my area of expertise — DTS role here at Apple is to provide code-level support for the APIs in our various platform SDKs — but I think the droid you’re looking for is sysadminctl.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thank you for your response. I've been redirected back and forth by Apple Support and Developer Support channels multiple times in multiple ways now so I will try to at least cross post in communities per your suggestion.

I've been trying to use sysadminctl recently as well and that is still giving the same type of roadblock - it works except the home folder is not creating unless an initial login happens.

Appreciate the moment and will continue to try and reach out for help hoping I find the gold mine of knowledge soon!