Create and Manage AD Users and Computers
Now we have the understanding of how and what an Active Directory
Domain is and the terminology that is used and what are the roles and
functionalities of the Domain Controller.
Next up, we will look at the objects that can be part of the Domain, like Users and Computers.
In today’s objective, we will be looking at:
- Create, Copy, Configure and Delete Users and Computers.
- Configure Templates.
- Configure User Rights.
- Automate the creation of AD accounts.
- Manage Inactive and Disabled accounts.
- Perform Bulk AD operations.
- Offline Domain Join.
Create, Copy, Configure and Delete Users and Computers
Users and Computers are one of the most important objects of the Active Directory Domain.
In this section, we will see the various ways available to create them.
Using Active Directory Users and Computers
To launch ADUC on your Domain Controller, go to Server Manger > Tools > Active Directory Users and Computers.
You can also go to Run and type dsa.msc to launch ADUC.
Right Click on any OU > New > User.

Provide the basic details like the First Name, Last Name, and the User logon name to create the user account.
Similarly, you can create a Computer account, by right clicking on an OU > New > Computer.

You just have to provide the computer name to add the object to the domain.
Using Active Directory Administrative Center
Administrators when using Windows Server 2003 and Windows 2008 had
only the option of ADUC when managing objects in the AD domain.
From Windows Server 2008 R2 onwards, Microsoft introduces Active
Directory Administrative Center, which is another of managing the Domain
and is completely built on PowerShell.
I really like this tool as it is very modern and has some really cool features.

As you can see, the design is very modern and it is a little more intuitive than the ADUC.
Similarly, you can create both Users and Computers using this tool.
Using dsadd
dsadd is a command line utility available from Windows Server 2008.
This utility will only be available if the ADDS Server Role is
installed.
Dsadd
Applies To:
Windows Server 2003, Windows Server 2008, Windows Server 2003 R2,
Windows Server 2012, Windows Server 2003 with SP1, Windows 8
Adds specific types of objects to the directory.
Dsadd
is a command-line tool that is built into Windows Server 2008. It is
available if you have the Active Directory Domain Services (AD DS)
server role installed. To use dsadd, you must run the dsadd command from an elevated command prompt. To open an elevated command prompt, click Start, right-click Command Prompt, and then click Run as administrator.
Command | Description |
Dsadd computer | :Adds a single computer to the directory. |
Dsadd contact | :Adds a single contact to the directory. |
Dsadd group | :Adds a single group to the directory. |
Dsadd ou | :Adds a single organizational unit to the directory. |
Dsadd user | :Adds a single user to the directory. |
Dsadd quota | :Adds a quota specification to a directory partition. |
dsadd user CN=AdilArif,CN=NewUsers,DC=enterprisedaddy,DC=com -pwd Password -disabled No
This will create a user called AdilArif in the NewUsers OU with the above password.
By default, the user is created and disabled, hence we are providing the parameter as NO.
Similarly, you can create computer account as well.
dsadd computer CN=Server1,CN=NewComputers,DC=enterprisedaddy,DC=com
Using PowerShell
Microsoft has made it very easy to administer most of the services of Windows Server using PowerShell.
How to create Active Directory Users with Powershell
his is going to very interesting post as I will telling you different
ways of creating users within Powershell. First things first, you need
to make sure that you have Powershell installed on your machine. And
also try and have Powershell 3.0, because it has some cool features from
its predecessors. You can download Powershell 3.0 from here
.
Once done, verify the version of Powershell opening up a Powershell
window from start menu. Make sure you open the window by right-clicking
and
Run as Administrator. If you don’t, then trust me friends, BAD things happen!
You should see something similar to the below image.

Now that we have taken care of the prerequisites, lets get to the meat of the article.
The cmdlet that helps you with creating a new user in an Active Directory domain is
New-ADUser
. I am sure that was difficult to guess. No it wasn’t!!
Trust me guys, the Powershell team has made it extremely easy for us
to understand and use this cmdlets. They follow the Verb-Noun naming
convention.
I always recommend that once you hear or know a new cmdlet, get the
help files related to it and spend some time understanding it! The way
you get the help is by simply typing the below:
Get-Help New-ADUser
You can also add different parameters at the end to get different
forms of help file. Simply append -Examples to the above line and see
what happens.
Voila! It gives a complete info along with a few examples as to how you can use that cmdlet.
Now lets go ahead and add a real user!
New-ADUser Ronnie
Assume that you want to see the user that you just created now. Do
not worry my friends, it could not have got any simpler, just type the
below:
Get-ADUser Ronnie

Powershell will show everything that it has related to Ronnie. By default it shows only a few properties related to the user.
Let us say that you want to see all the properties associated with the user.
Get-ADUser Ronnie -Property *
The user Ronnie does not have many properties associated with him.
You can see that there are lot of places that are left blank. That is
because when we create Ronnie, we just gave his First Name.
Let us add his Last Name and give him a description so that you can easily find anything you want about Ronnie in future.
For this we will be using the Set-ADUser cmdlet. But you can also use Set-ADObject if you like to.
Again, I highly recommend that you go through the help files for each cmdlet that I have introduces in this post.
Get-ADuser Ronnie | Set-ADuser -Description "Ronnie is from the Marketing Team" -SurName "Hopkins"
This was fun until you have couple of users to add. Imagine you get a
list from someone saying that you have add 200 users today! I am sure
that is going to be a pain.
Most often people will give the list of users with a csv file.
Powershell lets you play with the csv files easily and make changes as
per your wish. Assume that I have a csv file named newusers.csv
Make sure the first row of the csv file contains only the properties that are associated with the New-ADUser cmdlet.
#View users from CSV
Import-CSV ".\users.csv" | Out-GridView
Out-Grid View is just going to show the list on my screen in a nice format!
# Import users from CSV
Import-CSV ".\newusers.csv" | New-ADUser
We just imported the users and added them to the domain.
Before we continue, let us create a new Organizational Unit at the root of the domain.
New-ADOrganizationalUnit NewUsers
# Import users from CSV, set password, enable
Import-CSV ".\newusers.csv" |
New-ADUser `
-Enabled $True `
-AccountPassword $(ConvertTo-SecureString "P@55word" -AsPlainText -Force) `
-Company 'Enterprise Daddy.' `
-Path 'OU=NewUsers,DC=enterprisedaddy,DC=com'
In the above example we started to add the properties to the User
accounts on the fly, the properties that were not mentioned in the csv
file. Powershell gives you that flexibility and complete control.
Also note the character ` which you will find below the Esc key, this
helps you make your code look clean and continue to the next line.
Powershell will consider as though the code is continuing and is in the
same line.
Configure Templates
In some cases, you are asked to create single user accounts, but they
contain so many attributes, that it can be a time-consuming process.
We saw above that we can speed this up using various methods like dsadd.exe and New-ADUser cmdlet.
But there is another method in which you can create a user template.
A user template is a standard user account containing the most common
attributes within the organization. You would usually start the name of
the with the underscore.
Now if you have to create a user based on the template, you simply
have to right click on the template from ADUC and click on Copy.

Now you can enter the required information and enable the account.
Configure User Rights
To configure User Rights on a single machine, from Server Manager
> Tools > Local Security Policies > User Rights management.

As mentioned before, the above mentioned is used for a single computer.
To configure for a whole of computers, we need to use Group Policy, which we will be discussing in the upcoming articles.
Automate the creation of AD Accounts
Some of the old ways of doing this are:
Using csvde.exe
A command line utility that can create new AD DS objects by importing from a CSV file.
The
‑i parameter specifies import mode; without it, the default mode of CSVDE is export. The
‑f parameter identifies the file name to import from or export to. The
‑k parameter is useful during import operations because it instructs CSVDE to ignore errors.
The syntax is as below:
csvde.exe -i -f <filename.csv> [-k]
Using ldif.exe
Like csvde.exe but with more functionality, LDIFDE is a utility that
can import ADDS information and use it to add, delete or modify objects.
anage InActive and Disabled Accounts
For inactive accounts, the old way of doing it was to check the last
logon date. This is when the user would have accessed the domain.
You can use PowerShell to achieve this.
Get-ADUser -Filter * -Properties lastLogonDate | Format-Table Name, lastLogonDate

To check disabled account, the old way is to check the account was enabled using the Get-ADuser cmdlet.
Get-ADUser -Filter {enabled -ne $true}

In the new OS, we have a new cmdlet to easily find inactive and disabled accounts.
Search-ADAccount -AccountDisabled
The above will list both the Users and Computer objects that are disabled within the domain.
Search-ADAccount -AccountDisabled -UsersOnly
Only Disabled user accounts will be displayed.
Similarly for Inactive accounts, you can check as below.
Search-ADAccount -AccountInActive
For Password related issues.
Search-ADAccoun t -PasswordExpired
Search-ADAccount -PasswordNeverExpires
Search-ADAccount -LockedOut
Perform Bulk AD Operations
As discussed in the above section, csvde.exe, ldif.exe, and
PowerSehll were a few ways wherein one can automate the process of AD
object creation, deletion and modification.
Offline Domain Join
During an offline domain join, a computer is configured to join a domain without contacting a domain controller.
This makes it easy to join the computers to the domain where there is no network connectivity.
I have written a complete guide on how to perform this procedure which you can find below.
Offline Domain Join – Add computers to domain
Windows Server 2008 R2 and Windows 7 introduce a new option for joining computers to a domain, called offline domain join.
As
the name suggests, this features lets you join a computer to the domain
if there is no network connectivity or the computer cannot contact the
domain controller.
For this, we will be using a command called
Djoin.exe on a computer which is part of a workgroup with the information required to join to the domain.
When would you use Offline Domain join feature?
This is an important that can be used for datacenters, virtualized
desktop environments, where the machines are built and provisioned on
demand.
It can also be used when the machine is built and used in a lab
environment usually disconnected from the actual network. So when the
machine is first started up when part of the network, it will already be
a member of the domain. This also helps apply the required Group Policy
at the start up.
What are the steps to be performed for Offline Domain Join?
Basically there are four major steps that need to be performed to
join a computer to the domain using the Offline Domain Join method.
- Log on to the Windows Server 2008 R2 running the Active Directory
Domain Services or Windows 7 machines running RSAT tools with the
account having permission to add computers to the domain. (Domain Admins
group has this permission by default)
- Use the DJoin command to provision a computer for offline domain
join. This step prepopulates Active Directory with the information that
Active Directory needs to join the computer to the domain, and exports
the information called a blob to a text file.
- At the offline computer that you want to join the domain use DJoin to import the blob into the Windows directory.
- When you start or restart the computer, it will be a member of the domain.
Now that you understand the requirements to perform the Offline
Domain join of a computer, ;ets dig in further to see how will you go
about doing the same.
NOTE: The user who will perform this actions need to
be a part of Domain Admins Group or should have equivalent permissions
to add computers to domain.
Provision a Computer in Active Directory for Offline Domain Join
Run Djoin.exe from an elevated Command Prompt to provision the
computer account in Active Directory. The basic syntax of DJoin is as
follows:
djoin.exe /provision /domain DomainDNSName /machine ComputerName /savefile Filename
where
/provison
parameter creates new computer account in
Active Directory. You can also /reuse parameter if the computer account
already exists in AD.
DomainDNSName
is the DNS name of the domain. In our case it will be enterprisedaddy.com
ComputerName
will be the name of the computer to be created or reused.
Filename
will be the path and name of the File that we will output the blob to.
Now let us see an example of the command that we will be using in our demo here.
djoin.exe /provision /domain enterprisedaddy.com /machine CLIENT02
/savefile C:\CLIENT02_Join.txt /machineOU
“OU=NewComputers,dc=enterprisedaddy,dc=com”
Note that I have given an extra parameter called machineOU which will
create a computer account in the OU called NewComputers under root
domain.
Similarly you can use switches like /dcname domainControllerName to define which DC you want to create the account in.
Moving ahead, the computer account called CLIENT02 will be created in
NewComputers OU and information will be exported to the path
C:\CLIENT02_Join.txt
So we have completed the steps that need to performed in Active
Directory. Now this information needs to be injected in the computer
that has to joined by the offline method.
Perform an Offline Domain Join
The account metadata that was exported in a blob to a text file by
using Djoin.exe /provision can be imported to a computer, after which
the computer will become a domain member at the next startup.
The command that you will run on the computer and its syntax can be seen below:
djoin.exe /requestODJ /loadfile Filename /windowspath %SystemRoot% /localos
where:
/requestODJ
specifies that you want to perform an offline domain join operation.
Filename
is the path and file name of the text file that
contains the account metadata blob. This is the file that you created
by using Djoin.exe /provision.
%SystemRoot% is the built-in Windows variable that represents the directory in which Windows is installed.
/localos
specifies that you are injecting the domain join information into the local computer.
In our case, the command will be below assuming we have copied the file to the C drive of the local machine:
djoin.exe /requestODJ /loadfile C:\CLIENT02_join.txt /windowspath %SystemRoot% /localos
That’s it! Now when the computer is connected to the domain and is
started, it will automatically add itself to the domain and be a member
of the domain.