Build_Replica_DomainController

Build Replica Domain Controller using PowerShell

 Build Replica Domain Controller 

Automate Active Directory Domain Controller promotion in under 30 minutes โ€” on-premises or Azure.

๐Ÿ“˜ Wiki  |  ๐Ÿ’ผ LinkedIn


๐Ÿ“‹ Overview

Promoting a replica Domain Controller over the network using the traditional DCPromo / GUI method is a notoriously slow process โ€” often taking 4โ€“5+ hours when the NTDS.DIT database is large or the network is constrained.

This PowerShell automation uses Install From Media (IFM) to dramatically shrink promotion time:

Method Typical Time Network Dependency
Traditional DCPromo (GUI) 4โ€“5+ hours High โ€” full AD DB replication
This Script (IFM-based) ~20โ€“30 minutes Low โ€” only delta sync after promotion

โœ… Successfully tested in production environments, both on-premises and on Azure Virtual Machines.


โš™๏ธ Prerequisites

Requirement Details
Existing Domain Controller At least one DC must be reachable on the local network
WinRM Must be enabled on the target server
NTDS.DIT Size Optimised for databases within 10 GB
DSRM Password Must be supplied by the Administrator at runtime
Permissions Domain Admin or equivalent

๐Ÿš€ Operations


1๏ธโƒฃ Deploy the First DC โ€” Build a New Forest

Use this block to promote the first Domain Controller in a brand-new AD forest. This is a one-time operation when standing up a new domain from scratch.

#
# Windows PowerShell script for AD DS Deployment โ€” New Forest
#
Import-Module ADDSDeployment

Install-ADDSForest `
    -CreateDnsDelegation:$false `
    -DatabasePath          "C:\Windows\NTDS" `
    -DomainMode            "WinThreshold" `
    -DomainName            "bshwjt.internal" `
    -DomainNetbiosName     "BSHWJT" `
    -ForestMode            "WinThreshold" `
    -InstallDns:$true `
    -LogPath               "C:\Windows\NTDS" `
    -NoRebootOnCompletion:$false `
    -SysvolPath            "C:\Windows\SYSVOL" `
    -Force:$true

๐Ÿ’ก Update -DomainName and -DomainNetbiosName to match your environment before running.


2๏ธโƒฃ Build a Replica DC Using IFM (Install From Media)

This is the core automation โ€” promoting an additional DC into an existing domain using an IFM backup, bypassing full network-based replication.

โš ๏ธ Important: Once DC promotion is complete, remove the IFM backup immediately to avoid leaving sensitive AD data on disk.

#
# Windows PowerShell script for AD DS Deployment โ€” Replica DC via IFM
#
Import-Module ADDSDeployment

Install-ADDSDomainController `
    -NoGlobalCatalog:$false `
    -CreateDnsDelegation:$false `
    -Credential              (Get-Credential) `
    -CriticalReplicationOnly:$false `
    -DatabasePath            "C:\Windows\NTDS" `
    -DomainName              "bshwjt.internal" `
    -InstallationMediaPath   "C:\IFM" `
    -InstallDns:$true `
    -LogPath                 "C:\Windows\NTDS" `
    -NoRebootOnCompletion:$true `
    -ReplicationSourceDC     "DC01.bshwjt.internal" `
    -SiteName                "Default-First-Site-Name" `
    -SysvolPath              "C:\Windows\SYSVOL" `
    -Force:$true

๐Ÿ“ Important Notes

# Note
โฑ๏ธ Build time varies based on VM performance and network speed
๐Ÿ” SYSVOL will automatically reconstruct after the first reboot
๐Ÿ”„ A manual reboot is required after promotion completes
๐Ÿ“ Additional diagnostic logs are written to C:\temp
๐Ÿงช Tested successfully in production โ€” but always validate in a non-prod environment first
โ˜๏ธ Verified on both on-premises and Azure Virtual Machines

๐Ÿ” Promotion Flow

  Target Server (WinRM enabled)
          โ”‚
          โ–ผ
  Copy IFM Backup to C:\IFM
          โ”‚
          โ–ผ
  Run Install-ADDSDomainController
  (IFM path supplied โ€” minimal network replication)
          โ”‚
          โ–ผ
  Promotion completes (~20โ€“30 min)
          โ”‚
          โ”œโ”€โ”€โ–ถ Delete IFM backup from C:\IFM  โš ๏ธ Do this immediately
          โ”‚
          โ–ผ
  Manual Reboot
          โ”‚
          โ–ผ
  SYSVOL reconstructs automatically
          โ”‚
          โ–ผ
  โœ… Replica DC online โ€” logs in C:\temp

๐Ÿ“š Further Reading


๐Ÿค Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.


๐Ÿ“˜ Wiki  โ€ข  ๐Ÿ’ผ Connect on LinkedIn