In this lesson I will practice with manage any user and computer objects will be focusing on accomplishing
the following tasks.
You then power Shell will be creating new user and computer accounts modifying user and computer objects
enabling and disabling the user and computer accounts.
More than a user and computer accounts delete an user and computer accounts.
As you may know Active Directory is all about Users and Computers.
Each user in the organization will have at least one account.
There will be scenarios where a single user can have multiple accounts.
This is very true in the case of I.T. users where one account is used for regular activities such as
checking email browsing and so on whereas the other privileged account is used for managing the infrastructure.
Apart from this there are service accounts that are designed to run a particular service.
This shows how rapidly user accounts can grow in Active Directory environment along with the necessity
to manage them in a much more efficient way.
In the following lesson will be explaining how to perform User object operations using power shall.
So let's begin with creating user accounts managing user accounts is one of the day to day jobs.
As a Windows administrator new user adjourn companies on a frequent basis and sometimes the Walden might
go high in such cases creating user accounts using conventional methods is a time consuming and involves
errors.
So the best choice in that case is automation.
It produces less errors and it's less time consuming inactive directory.
The manual account creation process involves graphical user interface or guru such as active directory
Users and Computers and Active Directory administrative center.
First let's take a look at how user creation can be done using Active Directory administrative center.
It relies on an Active Directory power shall come on lads and to use them in the background to perform
the Active Directory operations.
We can started by clicking on server manager and once our manager is launched.
We go to the upper right corner click on tools manager and launch Active Directory administrative center
and the left side.
We have to select our domain in my case it's control so when we select the domain the new tasks pain
will show up in the right part of this window.
Here you can find this new bottom will click on it and select new user.
There are two mandatory fields that must be provided in order to create a user account.
Full name and user Sam account name.
Other fields are optional at the time of user creation and can be updated later.
You might have also noticed that the password is not specified at the time of creation so active directory
keeps this field in a disabled state until the password is set.
Once the password is said by the administrator the user object has to be enabled explicitly.
Similarly when a user account is created using power shell it has to be one mandatory property that
must be passed the name parameter.
This parameter is equivalent to the full name while in UI.
Also the same parameter while you is used for the user same account name attribute that at the same
time of user account creation use and power shall user account in Active Directory can be created using
the new Dash 80 user command led.
So let's launch power shall integrate its grouped in environment or IIS e and run the following command.
New dash a user the name parameter and will specify user name.
I'll type.
Test user 1 for the testing purposes when this amount is executive executives from the power show vendor
it creates a user account turns the default user container they count created will be in a disabled
state because no password has been provided at the time of creation.
This behavior is different when you create users using Active Directory Users and Computers console
where providing a password is mandatory as you can guess these commands that we have run is not sufficient
for creating user accounts in the production environment.
You are required to provide well use for different attributes such as First Name Last Name display name
password two options such as user must change password to the next time a smart office address phone
numbers job title department and so on.
So we need to enhance our code to populate these properties.
At the time of log game before we start creating a full fledged user account let's see which properties
can be populated by the new Dash 80 user command led at the time of user creation.
You can get this simply by running the following help command get help knew the shady user detailed
they get help command.
You could also type just help.
So this command led to the power shall command led to use and see the help content of any other command
led the usage of detailed switch tales get help command led to Rahm.
All the help content for the given command led.
It includes a list of parameters that seem to ex an explanation of parameters and examples which is
very useful when you run this command.
You can find that there are various properties called attributes.
You can set these attributes at the time of user creation.
If the attributes you want to set is not present then you can use the other attributes parameter to
set it.
Note that you need to provide other attributes NAMES AND WELL USE IN hash table format while pass on
to the other attributes parameters will take a closer look at this hash tables later on when we'll be
talking about modifying the user properties.
Now let's see how we can create an user account by pass and all kinds of values that we want to set
at that same time of user creation.
In this example will cover some of the properties that are frequently used to the time of user object
creation.
However you can modify this command and play around with set in other parameters.
And remember that practice makes one perfect the path through parameter is used to return the user object
after creation of the account.
If this parameter is not specified the command left will not show you any output after successful creation
of the object.
So first we need to prepare a password for the user to do the certain since the account password Come
on let requires the input to be in secure strewn format.
We need to populate the password variable with the desired password as shown in this command.
So in this command we create a variable which is equal to read.
Host come on led with as secure as tree and parameter it means that everything that we type will be
passed a secure stream to this wearable.
And this will prompt you to enter the password and you'll see asterisk symbols as you enter.
Ensure that the password to your enter should meet the password complexity of your domain.
Otherwise the following command will fail.
Now let's create a new user with the following command.
We'll do that with the new ADA user command led with name parameter given name email address same account
name account password that will be used in the variable which we have created before.
Display name department can't receive the best parameter which will ensure that the account will be
created in the needed overview and enabled parameter.
Which means that the account will be enabled enabled after creation pass through parameter.
I will he mentioned it will show us the result of this command again about pass parameter.
Ensure that you update pass parameter to reflect the distinguished name of the O U in your environment.
Otherwise the operation might fail.
And also please know that pass parameter is optional.
If you don't specify this the user account will be created in the default users container.
And when we run this command the power Shell will return the output as follows the output shows the
path of the object where it is created and other properties with set during the creation process.
By default the output shows only a minimum set of attributes.
You can see all current attributes and the values of user object using the get a the user command led.
So let's run it get a user with identity parameter and we have to specify the user we are looking for.
And after that properties parameter and asterisk which will find all the properties for the user we
are looking for and we can see the output of this command.