Creating multiple / bulk users in "Active Directory" using CSV file & PowerShell

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
thank you [Music] hello everyone hope you're doing well today let's create multiple users or bulk users in active directory using Powershell so let's see what we have on the agenda today so we'll understand the process of creating bulk users will understand the CSV file contents will understand the Powershell script and the relationship between the Powershell script and the CSV file and we'll run through some demos we'll run the script and create multiple users so let us understand the process of creating multiple users or bulk users and active directory so we'll create a CSV file with all the contents which we require and this file will be used as an input file for Powershell the Powershell will read this particular file and create multiple users in active directory in one go so comma separated value or CSV file again a CSV file is a normal text file that has specific format which allows data to be saved in a table structured format and we can create a CSV file in Microsoft Excel by save as dot CSV extension and this is how a typical CSV file looks like at the top you can see the extension is dot CSV so let's jump on to the demos then so we will understand the contents of the CSV file will understand the Powershell script and also will understand how the script will read the contents of the CSV file and then we'll run this script to create users in bulk in active directory so let's jump on to the labs then welcome to the labs now this is the Powershell script which is the dot CSV input file so let me walk you through the Powershell script the first thing is we will import the active directory module for Powershell and then we will create a variable and it's 80 users and we'll add the contents of this CSV file in this variable ad users so we'll import CSV from this particular CSV file and store it in this ad users variable now Loop through each row containing user details in the CSV file so for users in this ad users variable it will read the content of each and every row and it will again create a new variable for the user account see over here so it will store the username and this username variable password over here first name last name and the OU the organizational unit in which we need to create the users it's we are if we have already defined that OU in our CSV file so all the users will be created in the OU name test under contoso.com root after storing the variables what it will do is next thing is it will check if the user is already present in active directory or not so it if the user is already present it will not create the user and will get a message a user account with the username already exists in active directory otherwise it will start creating the user accounts so it will replace the username with Sam account name and UPN with the username at contoso.com that's our domain and so on and so forth so it will run the entire say uh account creation for each and every user here over here account password is say uh converting into text and change password at next logon is equal to false so user won't be able to prompt it to change the password at next log on and let's move on to the CSV file now so we have first name middle name last name display name username this logon name Sam account name email address UPN street address so whatever you see in row number one are the properties or attributes of a typical user account so let me show you this inactive directory so this is our active directory let me go to any of the users over here so these are all the attributes which we will be filling up for our users so I've already imported the script over here in Powershell integrated scripting environment and I have already created an OU named test over here so currently it is blank so let's run the script and check so the script is present under C temp the script is present over a year the sorry the CSV file cop this is the CSV file in see text so let's run the script and let's see the output over here what output we get okay the script went fine without any error so I think we need to Simply refresh the screen and perfect so we have all the test users or users in both we have inputed the users in bulk in the test OU now what we'll do is we will delete all users just keeping say few users over here okay check if the script will prompt us that the user is already created so let's say Clara say Elena so we just keep these two users and we'll delete all the other users and we'll run the script again so the script should prompt us that Clara and Elena these two users are already present so let me run the script again see over here user account with the username Clara already exists in active directory and same thing goes with say Elaine Elena so let me refresh it again and here we go so this is how we can import bulk users in active directory now you can also tweak this particular Powershell script and this particular CSV file as per your requirement what I'll do is I will say leave a link to download the script and the CSV file on the Google Drive okay so thanks for joining so let's summarize today's video so we have understood the bulk user creation process we have understood what a CSV file is and the file contents we've understood the Powershell script and we have also understood how the Powershell script reads the contents of the CSV file and we ran the Powershell script to create bulk users and active directory a session and thank you for joining and if you feel this channel is helping you to learn anything new Please Subscribe and share this video with your technical community and enjoy your day [Music] foreign [Music]
Info
Channel: DCTechNet
Views: 3,334
Rating: undefined out of 5
Keywords:
Id: LL2akSHDfEo
Channel Id: undefined
Length: 10min 1sec (601 seconds)
Published: Fri Jun 30 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.