So far we've seen how to create a single user account an Active Directory.
Now let's explore how to create multiple user accounts in one go.
The following command is sufficient enough if you want to create bulk user objects in the lap environment
without worrying about other properties such as Department email and so on.
So let's review this command and this command we are creating 100 users.
Of course you can create more or less users like you can create from 1 to 25 from 1 to solve them to
users and for each user we are given a name lab user and the number so the user will be created like
lap User 1 lap USER 2 and so on.
The password for each user will be equal to this variable which we have provided before and the users
will be created in lap over you.
So let's run this command and off to the check it inactive directory administrative center.
The command is completed and we can go to Active Directory Administrative Science Service Center and
check the newly created users in the lab.
Oh you as you can see it is populated now with the newly created users so it's as simple for reach loop
that runs 100 times or whatever number of times you need to create a user account with a name lab user
and SOF XT by the number of iterations such as as I've said lab user 1 a lab user 2 and so on with the
password set to the value of the password available.
However this is not sufficient to create accounts in production environment.
We need to populate several attributes at the time of creation.
Ideally system administrators receive their account creation information from H.R. department or in
some other department and ideally they receive it in CSP format and we can have the CSP file which will
be read by power shell and we shall have the details of user attributes and create user accounts based
on this information.
So to read that CSP file from a power shell variable we have a special command led for it a command
led called import does Cicely and it can read the contents of the CAC file and return the output in
object format.
We can make use of it to read the contents with the following command.
Let's create a variable which will call users and fields will be equal to import.
This is free and we have to specify the pass to the saved as we file.
Len will read this variable and output it in format table view so it'll show the contents of the variable
in table format just for testing purposes.
I've downloaded such a file and says for format from Microsoft Web site you can create such a file by
yourself or also do download it from Microsoft's Web site.
Now we have all user details in this file file so let's proceed to create user accounts from this file
and we'll do that with the following command first will import this file of us the past variable then
we'll read this file with for each command and for each user and this file will add the following properties
display name given name.
Name surname same account name.
The account will be enabled and password never expires.
For this account also will give user principal name proper to account password.
Will you read it from the variable which we've added before and the past to this account will be like
that.
Your past could be different so make sure you specify the correct path to the you in your environment
in case you don't specify pass parameter it'll put the account into the default or you.
Which is user so you and will perform a twist pass through parameter which will show the results of
the command.
Now let me open the file I've created from which will populate these parameters.
As you can see we've got all this information in this file and as you can imagine we can add and populate
the information we need.
For example if we need to add e-mail we can do this by type in e-mail here.
And we also have to type e-mail in each of the lines of this file for example for John Doe account will
have Jane Doe at come to us dot com for Chris Green account will have C green at com torso dot com.
We could also add telephone number for this we add phone parameter on the upper line and we add the
telephone for each account like this.
I'll let a telephone for John Doe 1 2 3 eleven eleven and to telephone for Chris Green on two three
eleven twelve.
And of course we have to add these parameters in our script so we'll add the line here like email address
which will be equal to variable user and email.
We also have to add phone number as parameter office phone and it will be equal to the variable dollars
sign user dot phone and it will populate the new users with the needed parameters.