Setup first Domain Controller using Powershell

This tutorial shows you how to setup the first Domain Controller (new AD DS Forest) using Powershell. For this tutorial, Windows Server 2016 Standard Edition without Desktop Experience has been used , but it can also be used for Windows Server 2019 en 2022. This edition was known as Core Edition in previous Windows Server editions.

Additionally, install a Certificate Authority, Certificate Authority Web Enrollment or DHCP service on the server.

To configure the network adapter and change the hostname using Powershell, use this tutorial:

Log in as Administrator. A Command Shell is shown. Type ‘powershell’ and hit enter.

To install the Active Directory Domain Services, use the Install-WindowsFeature cmdlet.

Install-WindowsFeature AD-Domain-Services

In this example, a new forest will be created by creating a new root-domain. The name of the root-domain will also be the name of the Forest. The root-domainname will be ‘lab01.local’, and DNS will be installed on the domain controller. The Domain- and Forest Functional level will be set to Windows Server 2016 (7) and reboot the server after the installation. If there is already a separate DNS server/appliance, e.g. Infoblox, the ‘InstallDns’ parameter should be set to false (-InstallDns:$false).


Install-ADDSForest -DomainName "lab01.local" -DomainMode 7 -ForestMode 7 -InstallDns -NoRebootOnCompletion:$false -SafeModeAdministratorPassword (Get-Credential 'SafeModeAdministratorPassword').Password

After the reboot you have a fully functional domain controller.
Because the domain controller is also DNS server, you might want to set DNS Forwarders. Use the Set-DnsServerForwarder cmdlet to set the forwarders. For example, use the Google DNS server addresses, or any other public DNS server address.


Set-DnsServerForwarder -IPAddress,

You have completed your first Domain Controller installation using Powershell!

If you want to install a Certificate Authority on the Domain Controller using Powershell, use this tutorial:

If you want to install DHCP on the Domain Controller using Powershell, use this tutorial:

2 thoughts on “Setup first Domain Controller using Powershell

  1. PS C:\Users\Administrator> Install-ADDSForest -DomainName “Testlab2016.local” -DomainMode 7 -ForestMode 7 -InstalDns:$tr
    ue -NoRebootOnCompletion:$false
    Install-ADDSForest : A parameter cannot be found that matches parameter name ‘InstalDns’.
    At line:1 char:80
    + … e “Testlab2016.local” -DomainMode 7 -ForestMode 7 -InstalDns:$true -N …
    + ~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Install-ADDSForest], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.DirectoryServices.Deployment.PowerShell.Commands.Instal

    Solved Error in Example ( -InstalDns:$true ==> -InstalLDns:$true)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.