You are on page 1of 12

How to Install Windows Active Directory from PowerShell Command Line http://www.thegeekstuff.

com/2014/12/install-windows-ad/

≡ Menu

Home
Free eBook
Start Here
Contact
About

How to Install Windows Active Directory from PowerShell Command


Line
by Satheesh Kumar on December 9, 2014

J’aime 62 Tweet

As a Linux Sysadmin, you might still find yourself managing few Windows Servers.

In those situations, instead of using the Windows GUI for administration, you might find it interesting to install and configure Windows Services from
command line.

In this tutorial, we’ll explain how to install AD (Active Directory) on Windows 2012 Core Servers using the following command line utilities.

1 sur 12 10/11/2017 à 23:22


How to Install Windows Active Directory from PowerShell Command Line http://www.thegeekstuff.com/2014/12/install-windows-ad/

install-windowsfeature
import-module
install-addsforest

There are two high-level steps to install AD. First, install the AD itself. Second, promote the server as domain controller.

You can install AD from server manager GUI interface as we explained earlier. But, if you are Linux sysadmin, you might find it interesting to use the
command line utilities instead of GUI.

1. Get AD Service Name

To begin the AD installation from the command line, we need to know the exact name of the Active Directory Service that we should install.

First, execute the “get-windowsfeature” command from the Windows powershell.

2 sur 12 10/11/2017 à 23:22


How to Install Windows Active Directory from PowerShell Command Line http://www.thegeekstuff.com/2014/12/install-windows-ad/

This will list all windows server features as shown below. As you see from this list, the AD service name is “AD-domain-services”.

2. Install AD Domain Service

To install Active Directory from the command line, use the “install-windowsfeature” command as shown below.
C:\> Install-windowsfeature AD-domain-services

This command will extract all required binary files and start the AD installation.

After completing the Active Directory installation, it will display the result in a table format as shown below.

3. Import ADDSDeployment Module

To increase the server performance all modules and commands are not loaded by default in the server. We have to import the modules as per our requirement.

To continue our AD installation and configuration, we need ADDSDeployment module. Import this module as shown below using import-module

3 sur 12 10/11/2017 à 23:22


How to Install Windows Active Directory from PowerShell Command Line http://www.thegeekstuff.com/2014/12/install-windows-ad/

powershell command.
C:\> Import-Module ADDSDeployment

4. Commands to Promote Server as Domain Controller

Next, promote your server as Domain controller based on your requirement using any one of the following commands.

Command Description
Add-ADDSReadOnlyDomainControllerAccount Install read only domain controller
Install-ADDSDomain Install first domain controller in a child or tree domain
Install-ADDSDomainController Install additional domain controller in domain
Install-ADDSForest Install first domain controller in new forest
Test-ADDSDomainControllerInstallation Verify prerequisites to install additional domain controller in domain
Test-ADDSDomainControllerUninstallation Uninstall AD service from server
Test-ADDSDomainInstallation Verify prerequisites to install first domain controller in a child or tree domain
Test-ADDSForestInstallation Install first domain controller in new forest
Test-ADDSReadOnlyDomainControllerAccountCreation Verify prerequisites to install Read only domain controller
Uninstall-ADDSDomainController Uninstall the domain contoller from server

5. Install First Domain Controller in Forest

In this example, we are installing the first domain controller in forest.

To install the Active directory with default configuration, execute “Install-AddsForest” command:
C:\> Install-AddsForest

To install the Active directory with customized options, pass the appropropriate parameters as shown below. IN this example, we are setting several
configuration parameters for our AD including the DomainName.

C:\> Install-ADDSForest
-CreateDnsDelegation:$false `
-DatabasePath "C:\Windows\NTDS" `
-DomainMode "Win2012R2" `

4 sur 12 10/11/2017 à 23:22


How to Install Windows Active Directory from PowerShell Command Line http://www.thegeekstuff.com/2014/12/install-windows-ad/

-DomainName "thegeekstuff.com" `
-DomainNetbiosName "THEGEEKSTUFF" `
-ForestMode "Win2012R2" `
-InstallDns:$true `
-LogPath "C:\Windows\NTDS" `
-NoRebootOnCompletion:$false `
-SysvolPath "C:\Windows\SYSVOL" `
-Force:$true

6. Complete the AD Installation

Finally, this will prompt for SafeModeAdministratorPassword. This password is for the Directory Services Restore Mode (DSRM).

Set your DSRM password here, which will finish the AD installation and configuration on your Windows Server using the command line utilities.

Tweet J’aime 62 > Add your comment

If you enjoyed this article, you might also like..

1. 50 Linux Sysadmin Tutorials Awk Introduction – 7 Awk Print Examples


2. 50 Most Frequently Used Linux Commands (With Examples) Advanced Sed Substitution Examples
3. Top 25 Best Linux Performance Monitoring and Debugging Tools 8 Essential Vim Editor Navigation Fundamentals
4. Mommy, I found it! – 15 Practical Linux Find Command Examples 25 Most Frequently Used Linux IPTables Rules Examples
5. Linux 101 Hacks 2nd Edition eBook Turbocharge PuTTY with 12 Powerful Add-Ons

5 sur 12 10/11/2017 à 23:22


How to Install Windows Active Directory from PowerShell Command Line http://www.thegeekstuff.com/2014/12/install-windows-ad/

Tagged as: Get-WindowsFeature Installed, Import-Module Active Directory, Install-AddsForest, Install-AddsForest DomainName, Install-AddsForest
Example, Install-AddsForest Script, Install-WindowsFeature Active Directory, Install-WindowsFeature AD-domain-services,
SafeModeAdministratorPassword

{ 5 comments… add one }

Ram December 10, 2014, 4:29 am

Q: Why user create in /home directory ?

Link
Arun December 12, 2014, 3:26 am

I am using Windows XP and I installed powershell . But the command get-windowsfeature didn’t get wored . Idon’t know why ?

Link
satheesh December 20, 2014, 6:00 am

Hi Ram,

In windows you can run the commands in all directory, So I ran commands in my home directory, but it will install in “C:\windows”.

Quetion

6 sur 12 10/11/2017 à 23:22


How to Install Windows Active Directory from PowerShell Command Line http://www.thegeekstuff.com/2014/12/install-windows-ad/

Link
Anthony Datu December 20, 2014, 3:48 pm

Hi Ramesh,

My question might be off topic, but do you happen to know if DBI-LDAP module works in Active Directory?

Thanks,
Anthony

Link
Matthias June 6, 2015, 6:15 am

Hello,
if i entered the command i will aksed after the DSRM Password. If i had entered the first and press enter i get an error message “no positionparameter
to accept SafeModeAdministratorPassword”.

What have i do wrong?

Thanks for your help

Link

Leave a Comment

Name

Email

Website

Comment

7 sur 12 10/11/2017 à 23:22


How to Install Windows Active Directory from PowerShell Command Line http://www.thegeekstuff.com/2014/12/install-windows-ad/

Notify me of followup comments via e-mail

Next post: How to Use libwireshark in C Program to Decode Network Packets

Previous post: How to Setup Logstash on Linux with ElasticSearch, Redis, Nginx

RSS | Email | Twitter | Facebook | Google+

Search

EBOOKS

Linux 101 Hacks 2nd Edition eBook - Practical Examples to Build a Strong Foundation in Linux
Bash 101 Hacks eBook - Take Control of Your Bash Command Line and Shell Scripting
Sed and Awk 101 Hacks eBook - Enhance Your UNIX / Linux Life with Sed and Awk
Vim 101 Hacks eBook - Practical Examples for Becoming Fast and Productive in Vim Editor
Nagios Core 3 eBook - Monitor Everything, Be Proactive, and Sleep Well

8 sur 12 10/11/2017 à 23:22


How to Install Windows Active Directory from PowerShell Command Line http://www.thegeekstuff.com/2014/12/install-windows-ad/

POPULAR POSTS

15 Essential Accessories for Your Nikon or Canon DSLR Camera


12 Amazing and Essential Linux Books To Enrich Your Brain and Library
50 UNIX / Linux Sysadmin Tutorials
50 Most Frequently Used UNIX / Linux Commands (With Examples)
How To Be Productive and Get Things Done Using GTD
30 Things To Do When you are Bored and have a Computer
Linux Directory Structure (File System Structure) Explained with Examples
Linux Crontab: 15 Awesome Cron Job Examples
Get a Grip on the Grep! – 15 Practical Grep Command Examples
Unix LS Command: 15 Practical Examples
15 Examples To Master Linux Command Line History
Top 10 Open Source Bug Tracking System
Vi and Vim Macro Tutorial: How To Record and Play
Mommy, I found it! -- 15 Practical Linux Find Command Examples
15 Awesome Gmail Tips and Tricks
15 Awesome Google Search Tips and Tricks
RAID 0, RAID 1, RAID 5, RAID 10 Explained with Diagrams
Can You Top This? 15 Practical Linux Top Command Examples
Top 5 Best System Monitoring Tools

9 sur 12 10/11/2017 à 23:22


How to Install Windows Active Directory from PowerShell Command Line http://www.thegeekstuff.com/2014/12/install-windows-ad/

Top 5 Best Linux OS Distributions


How To Monitor Remote Linux Host using Nagios 3.0
Awk Introduction Tutorial – 7 Awk Print Examples
How to Backup Linux? 15 rsync Command Examples
The Ultimate Wget Download Guide With 15 Awesome Examples
Top 5 Best Linux Text Editors
Packet Analyzer: 15 TCPDUMP Command Examples
The Ultimate Bash Array Tutorial with 15 Examples
3 Steps to Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id
Unix Sed Tutorial: Advanced Sed Substitution Examples
UNIX / Linux: 10 Netstat Command Examples
The Ultimate Guide for Creating Strong Passwords
6 Steps to Secure Your Home Wireless Network
Turbocharge PuTTY with 12 Powerful Add-Ons

CATEGORIES

Linux Tutorials
Vim Editor
Sed Scripting
Awk Scripting
Bash Shell Scripting
Nagios Monitoring
OpenSSH
IPTables Firewall
Apache Web Server
MySQL Database
Perl Programming
Google Tutorials
Ubuntu Tutorials
PostgreSQL DB
Hello World Examples
C Programming
C++ Programming
DELL Server Tutorials

10 sur 12 10/11/2017 à 23:22


How to Install Windows Active Directory from PowerShell Command Line http://www.thegeekstuff.com/2014/12/install-windows-ad/

Oracle Database
VMware Tutorials

About The Geek Stuff

My name is Ramesh Natarajan. I will be posting instruction guides, how-to, troubleshooting tips and tricks on Linux, database, hardware,
security and web. My focus is to write articles that will either teach you or help you resolve a problem. Read more about Ramesh Natarajan and the blog.

Contact Us

Email Me : Use this Contact Form to get in touch me with your comments, questions or suggestions about this site. You can also simply drop me a line to
say hello!.

Follow us on Google+

Follow us on Twitter

Become a fan on Facebook

Support Us

11 sur 12 10/11/2017 à 23:22


How to Install Windows Active Directory from PowerShell Command Line http://www.thegeekstuff.com/2014/12/install-windows-ad/

Support this blog by purchasing one of my ebooks.

Bash 101 Hacks eBook

Sed and Awk 101 Hacks eBook

Vim 101 Hacks eBook

Nagios Core 3 eBook

Copyright © 2008–2017 Ramesh Natarajan. All rights reserved | Terms of Service

12 sur 12 10/11/2017 à 23:22

You might also like