Now let's take a look at another situation when we want to perform bulk user enable disable operation.
There are two.
Come on let's provided an active drug to remodel to perform this operation when very easy and straightforward.
This command lets SA enabled dash ADR account and disable this 80 account.
The first one is used to enable Active Directory user computer or service account objects.
And the second one obviously is used for disabled and Active Directory user computer or service account
objects.
Both lists.
Come on let's require now object to be enabled to disable the object can be in one of the following
formats.
Distinguished name or d n format for example CNN Equals John comma or U equals slab D C equals com Tulsa
and the C equals A.D. or com.
The format could be also object do you I.T. Security identify our seed format or same account name format
together this values for a given user let's say for user John we could use get the say the user command
let we could also use get this a computer in case of computer accounts.
Now we have all only to pass the input values to either the enable does ADR count or disable dash Ada
account.
Come on let's.
Based on which operation you want to perform.
So let's disable first John's account was disabled the shady account there's identity John and pass
through parameter.
Again a reminder that path through parameter is used to return the object after the completion of the
operation.
Also it is useful to know the disabled status if you want to perform further actions on this object.
You can also disable users in a particular or you.
The following commands will return all user objects on the lap over you and it stops or stop or use.
Where are you then get a user command led surge based parameter and will be looking in lab.
Oh you will filter all the objects in this all over you.
That's what asterisks is stands stand standard for and will pipe the results of this command to disable
a discount command land so all the users which are allocated whizzes get a D user.
Command will be disabled again.
Just a reminder for you that pipe serves for moving the results of one command to another command to
limit the search scope to the current Oyu.
We could use this search scope parameter.
It takes three values basic or 0 1 level or 1 and a sub three or two sub three is a default value.
When you specify Northam let's move on and read user names from a text file and disable them.
We'll be doing that with get content command led and will be getting content from the file users the
60 and pipe the results to the following code.
So here they are.
Get content.
Come on let rates the user names from the text file and passes them one by one to the disable account.
Come on let using for each loop.
This percentage character means the same as for rich.
It is an alias for a for each loop in power shell.
So when passing the user name to the disabled ADR account.
Come on let me use the dollar character and underscore character automatic Y variable which contains
the name that is passed from the pipeline to it.
You can disable all users in a department for example sales.
We could run the following command queries all users who have their department values set to sales and
it passes them to the disable.
ADR account command led to disable them so the command looks like that go to the user filter department.
Equals sales and pipe at the results of this command to disable the account command land likewise to
perform an enable operation.
Just replace disable account A.D. account with will enable A.D. account command led.
In this example let's consider moving accounts to another you.
For example let's consider a scenario where all users of one department are moved from one office building
to another.
So you would like to move all this user accounts to an you or you for reasons of identification and
management.
The move does ADR object common letters available in Active Directory module to accomplish this operation.
This particular command led can move an object from one or you to another not just user accounts as
command led has 2m mandatory parameters identity and target path identity parameter identifies the object
that you want to move it can be either the distinguished name or the end of the object or the do you
idea of the object and other mandatory parameter is target.
Pass the target pass parameter must be the distinguished name of the OR YOU OR THE contain it to which
you want to move the object.
Let's take a look at the following command values and move this 80 object with identity join with which
is located in Aleppo you and we are moving it to the tech 0 you Richard stop or you of lap or you.
You could also move all the user from lab all you to production or you for example with the following
command get the user will be filtering all the users in lab or you and pipe the results to move dash
a the object command led and will be moving to production or you.
So once again this command will move all users including users in SOP or use from the lab.
Oh you're too broad are you.
And the identity parameter is automatically populated from the output of the guard.
There's a user command led.
You can use the following command to move users from one or you to another based on their department
name.
Let's say that we want to move all users who are in dept sales to the sales department which is in production.
We'll do that with get this a user filter and by department which has equal sales and move all this
users with move Dash 80 object to the OR use sales production in production.
Also remember that target or you must exist before you move users to.