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.
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 188.8.131.52,184.108.40.206
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: