- What
- Why
- How
- Step 1: Install AD DS Role on the First Server
- Step 2: Promote the First Server to a Domain Controller
- Step 3: Restart the First Server
- Step 4: Verify the First Domain Controller
- Step 5: Install AD DS Role on the Second Server
- Step 6: Promote the Second Server as an Additional Domain Controller
- Step 7: Restart the Second Server
- Step 8: Verify Both Domain Controllers
- Conclusion
What
This article provides a clear, concise guide on setting up Active Directory (AD) and adding a second domain controller using PowerShell commands on Windows Server.
Why
Automating the installation of Active Directory and deploying additional domain controllers via PowerShell ensures faster, consistent, and reliable setups. It enhances domain availability and redundancy without manual configuration.
How
Step 1: Install AD DS Role on the First Server
Install-WindowsFeature AD-Domain-Services -IncludeManagementTools
Step 2: Promote the First Server to a Domain Controller
Install-ADDSForest `
-DomainName "example.local" `
-DomainNetbiosName "EXAMPLE" `
-SafeModeAdministratorPassword (ConvertTo-SecureString "P@ssw0rd!" -AsPlainText -Force) `
-InstallDNS:$true `
-Force
Step 3: Restart the First Server
Restart-Computer
Step 4: Verify the First Domain Controller
Get-ADDomain
Get-ADDomainController
Get-Service DNS
Step 5: Install AD DS Role on the Second Server
Install-WindowsFeature AD-Domain-Services -IncludeManagementTools
Step 6: Promote the Second Server as an Additional Domain Controller
Install-ADDSDomainController `
-DomainName "example.local" `
-Credential (Get-Credential) `
-SafeModeAdministratorPassword (ConvertTo-SecureString "P@ssw0rd!" -AsPlainText -Force) `
-InstallDNS:$true `
-Force
Step 7: Restart the Second Server
Restart-Computer
Step 8: Verify Both Domain Controllers
Get-ADDomainController -Filter *
Conclusion
By following these steps, you can automate the deployment of a primary and secondary domain controller using PowerShell. This approach ensures a resilient and efficient Active Directory environment, supporting best practices for enterprise infrastructure.