Create local user account via Jamf createAccount - read password from local source file

kwsenger
Contributor

I am trying to create a local (non-AD) account on student laptops using bash and a .csv file. The User and Location field in the JSS is already set to the local user we want to create.

Workflow:
.csv spreadsheet contains rows of usernames and passwords
user1,password1
user2,password2
user3,password3

What we want next is to add a local user account based on the username $3 and have that username referenced in a .csv file. Then have the password in the next field go into a variable which is passed along to the createAccount -password attribute. This would be run either from a policy at check in (preferred) or from Self Service as the local admin user.

We can Create a user Manually in Terminal:
sudo jamf createAccount -username student1 -realname student1 -password newpassword -home /Users/student1 -shell /bin/bash

SCRIPT
#!/bin/sh
file="/Library/Application Support/JAMF/bin/userpasswords.csv"

username=$3
password= field number 2 in the .csv spreadsheet

#Lookup the username variable in the .csv spreadsheet and set the password in the same row as the password variable.
This is the step I need all the help on.

#Create the account
jamf createAccount -username $3 -realname $3 -password $password -home /Users/$3 -shell /bin/bash

#Delete the password .csv file
sudo rm $file

exit 0

0 REPLIES 0