Installing Additional AD Domain Controller using PowerShell

Hi Friends, I know that installing Windows AD Domain Controller is something not a trending technical topic currently to discuss but while building a lab scenario in my AWS environment I needed an Additional AD Domain Controller on an EC2 instance in my existing AD Domain “CloudMegh.local” so I just thought of writing this simple post.

Being an IT Infrastructure and Cloud professional, I used to be a guy who loved working via Windows GUI but later I realized the Power of the PowerShell and started exploring it.
So in this lab I’m going to install Additional AD Domain Controller using PowerShell. To start on this, I reviewed Microsoft docs document and found “ADDSDeployement” PowerShell module and this is going to help me here.

ADDS Deployment PowerShell Module:

  1. I’m going to install Additional DC on my below EC2 Instance running Windows Server 2016 OS.

    2. Let’s first login to this machine and add this machine to the domain “CloudMegh.local”. Run the below PowerShell cmdlet to add this machine to domain and the reboot the machine. If you add “-Reboot” switch to this cmdlet it will reboot the machine.
Add-Comuter -DomainName “CloudMegh.local” -Credential Get-Credential -PassThru -Verbose

Note: If you face any issues with Domain join and it doesn’t fix with general troubleshooting steps then you would need to investigate and debug domain join issue by looking at below log file on client side.

How to troubleshoot errors that occur when you join Windows-based computers to a domain

3. Now the below command to install ADDS Windows Feature.

Install-WindowsFeature AD-domain-services -Verbose

4. Now run the following cmdlet to import “ADDSDeployment” PowerShell Module.

Import-Module ADDSDeployment -Verbose

5. Now I would like to see what all PS Cmdlets are available in “ADDSDeployment” that can help me here. Run below cmdlet to find it.

gcm -Module "ADDSDeployment" 

6. So “Install-ADDSDomainController” is the one that is going to help me to install my Additional DC in my lab, I constructed this cmdlet with all the required parameters and now I’m going to execute below to get my new ADC installed.

Install-ADDSDomainController -CreateDnsDelegation:$false -DatabasePath 'C:\Windows\NTDS' -DomainName 'CloudMegh.local' -InstallDns:$true -LogPath 'C:\Windows\NTDS' -NoGlobalCatalog:$false -SiteName 'Default-First-Site-Name' -SysvolPath 'C:\Windows\SYSVOL' -NoRebootOnCompletion:$true -Force:$true 

Note: Once you execute above cmdlet you need to wait for sometime as installing DC takes few minutes. Please reboot once above cmdlets finishes.

7. Once you DC installation completed and you rebooted the machine, you can run below cmdlet just to verify this Additional DC.

Test-ADDSDomainControllerInstallation -Debug 

8. Now if you would like to see some more details about this new Additional DC, you may run below cmdlets.

Get-ADDomainController -Discover
Get-ADDomainController -Verbose 

You can explore all the cmdlets in Active Directory PowerShell module so that you can perform all the Active Directory administration and troubleshooting using PowerShell.

Note: I haven’t installed any RSAT tools yet, so lets go ahead and install RSAT tools on this machine. I always install all the Windows RSAT tools on my lab machines because I might need the one at any time.

Let’s run this one liner to get all the Windows RSAT tools installed on this machine and then restart the machine.

So this was all about this quick lab. Please don’t forget to comment if something needs to added or improved here.

1 thought on “Installing Additional AD Domain Controller using PowerShell”

  1. Well written, Sir 🙂
    Keep posting (y).
    You are doing a tremendous job. Just love your dedication and exploring abilities.

Leave a Reply

Your email address will not be published.