Add new Domain Controller to existing domain with PowerShell

Add new Domain Controller to existing domain with PowerShell

January 3, 2019

If you need the need to add a secondary domain controller, this script may help you.

This script was tested with Windows Server 2016.

Firstly, 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. Change the Domain\Admin with your own domain user.

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
-Credential (Get-Credential DOMAIN\AdminUser)
-CriticalReplicationOnly:$false `
-DatabasePath "C:\Windows\NTDS"
-LogPath "C:\Windows\NTDS"
-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 Comments

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

Copyright ©2023 All rights reserved