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
Install-WindowsFeature -Name AD-Domain-Services -IncludeManagementTools
Once
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 DOMAIN\AdminUser)
-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:

Yes