Add new Domain Controller to existing domain with PowerShell

This script was tested with Windows Server 2016. We need to install the ADDS server role on the server that will setup the domain controller using PowerShell:

Install-WindowsFeature -Name AD-Domain-Services -IncludeManagementTools

Once role is installed, we can use the following script to add a domain controller to the existing domain:

For security reason, we have not to write a plaintext password directly on a script so the domain join credentials, domain name, and DSRM password will be prompted.

# Windows PowerShell script for setup AD DS Deployment.
# Password for domain join credentials will be prompted.
# no DSRM password prompt.

Import-Module ADDSDeployment
Install-ADDSDomainController
-NoGlobalCatalog:$false
-CreateDnsDelegation:$false
-Credential (Get-Credential AMAN\administrator)
-CriticalReplicationOnly:$false `
-DatabasePath "C:\Windows\NTDS"
-InstallDns:$true
-LogPath "C:\Windows\NTDS"
-NoRebootOnCompletion:$false
-SiteName "Default-First-Site-Name"
-SysvolPath "C:\Windows\SYSVOL"

Fill the Administrator or administrators group’s credentials, domain name, and DSRM password. After that, there will be a confirmation below:

Type Yes to continue the operation, and wait for minutes until the process is done, and then reboot the server.

Leave a Reply

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