Powershell to Create Users
the_Grinch
Member Posts: 4,165 ■■■■■■■■■■
in Off-Topic
We're switching to a new expense system and will need to create around 71 user accounts. I have an Excel spreadsheet with the usernames, but I plan on making a new one with the following columns:
First Name
Last Name
Username
Password
Domain
Group (going to break them into groups by department)
Very rare that I get to do Server Administration tasks so haven't looked into Powershell very much, though I'd like to.
Any help will be appreciated!
First Name
Last Name
Username
Password
Domain
Group (going to break them into groups by department)
Very rare that I get to do Server Administration tasks so haven't looked into Powershell very much, though I'd like to.
Any help will be appreciated!
WIP:
PHP
Kotlin
Intro to Discrete Math
Programming Languages
Work stuff
PHP
Kotlin
Intro to Discrete Math
Programming Languages
Work stuff
Comments
-
cyberguypr Mod Posts: 6,928 ModCheck this one out: Script PowerShell: Create Active Directory Users Based On Excel Input
Just make sure you run a few tests before you throw a lot of users at it. -
phonetic.man Member Posts: 79 ■■□□□□□□□□Here is what I do for bulk student imports. It isn't Powershell (which I would like to learn) but it works.
Because of superstition, I run each task separately. I have done a fully automated script in the past, but I just don't trust myself due to all of the interruptions...
for /f "tokens=1,2,3,4,5 delims=," %a in (students.txt) do dsadd user "cn=%~b\, %~c,OU=%~d,OU=Students,dc=school,dc=edu" -samid "%~a" -fn "%~c" -ln "%~b" -display "%~b, %~c" -pwd Password1234 -desc "%~d" -memberof "cn=Students,OU=Groups,dc=school,dc=edu" "cn=%~d,OU=Groups,dc=school,dc=edu" -email "%~e" -hmdir "\\storagesvr\students\%~d\%~a" -hmdrv h: -mustchpwd yes -canchpwd yes
for /f "tokens=1,2,3,4,5 delims=," %a in (students.txt) do mkdir \\storagesvr\students\%~d\%~a
for /f "tokens=1,2,3,4,5 delims=," %a in (students.txt) do cacls "\\storagesvr\students\%~d\%~a" /t /e /g school\%~a:F
This is setup to work with an external text file structured as follows:
UserID,LastN,FirstN,GradYear,Email
Example:
Information - Name Johnny Jumpup, GradYear 2020, Email 20.jumpup.j@school.edu, ID jj123456789
Formatting in Text File (csv) - jj123456789,Jumpup,Johnny,2020,20.jumpup.j@school.edu
This creates the users in their OU, adds group membership, network drive (and full permission of their folder), and email address (in the email address field because we use Google as our host)Currently studying: Backup Academy, CWNA, MCSA:08, iBoss ISCP