Powershell to Create Users

the_Grinchthe_Grinch Member Posts: 4,165 ■■■■■■■■■■
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!
WIP:
PHP
Kotlin
Intro to Discrete Math
Programming Languages
Work stuff

Comments

  • cyberguyprcyberguypr Mod Posts: 6,928 Mod
    Check 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.manphonetic.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
Sign In or Register to comment.