Create User
Set the username and password
The first command uses the Read-Host
cmdlet to prompt you for a password. The command stores the password as a secure string in the $Password
variable.
The second command creates a local user account and sets the new account's password to the secure string stored in $Password
. The command specifies a user name, full name, and description for the user account.
dscl$Password .= Read-Host -passwdAsSecureString
/Users/$params = @{
Name = '<username>'
<password>Password = $Password
FullName = 'Full Name'
Description = 'Description of this user.'
}
New-LocalUser @params
Set the user's default shell
dscl . -create /Users/<username> UserShell /bin/bash
Set the user's display name
dscl . -create /Users/<username> RealName "Real Name"
Set the user's primary group
dscl . -create /Users/<username> PrimaryGroupID 1000
Set the user's home directory
dscl . -create /Users/<username> NFSHomeDirectory /Users/<username>
Promote user to local admin
dscl . -append /Groups/admin GroupMembership <username>
Set the user's ID
dscl . -create /Users/<username> UniqueID 510