Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

AD Lab Automation

PowerShell scripts for provisioning Active Directory lab environments. Covers initial machine setup, Domain Controller promotion, and workstation domain management.


Table of Contents


Overview

Three scripts, each with a distinct responsibility. setup.ps1 runs first on any machine. dc.ps1 and ws.ps1 handle role-specific configuration afterward.

setup.ps1  ──►  dc.ps1   (Domain Controller)
           ──►  ws.ps1   (Workstation / Member Server)

All scripts are parameter-driven — nothing executes unless explicitly invoked. Any parameter can be run in isolation or combined with others in a single call.


Scripts

setup.ps1

Initial machine configuration. Run this on every machine before any role-specific script.

Parameter Type Description
-LocalAdmin string Sets the local Administrator password
-Rename string Renames the machine and triggers reboot
-IP string Assigns a static IPv4 address
-DNS string Sets the DNS server address
-InterfaceAlias string Adapter name to configure (default: Ethernet0)
-PrefixLength int Subnet prefix length (default: 24)

-Rename triggers an immediate reboot. -LocalAdmin and -Rename must be run separately from -IP and -DNS — the reboot kills the session before network config can execute.


dc.ps1

Domain Controller role setup. Requires setup.ps1 to have run first.

Parameter Type Description
-ADDS switch Installs the AD-Domain-Services role
-NewDomain switch Creates a new AD forest
-ChildDomain switch Promotes the server as a child domain DC
-DomainName string FQDN for new forest, or child label for child domain
-ParentDomain string Parent domain FQDN (required for -ChildDomain)
-DSRMPassword string Directory Services Restore Mode password
-AdminUser string UPN for EA credential prompt (required for -ChildDomain)

-NewDomain and -ChildDomain both trigger an automatic reboot on completion.


ws.ps1

Domain join and machine management. Requires setup.ps1 to have run first, with DNS pointing to the DC.

Parameter Type Description
-JoinMachine string Joins the machine to the specified domain
-RenameMachine string Renames a domain-joined machine and updates the AD object
-Remove switch Removes the machine from the domain, rejoins WORKGROUP
-Verify switch Prints domain membership status and role
-AdminUser string UPN for domain credential prompt

-JoinMachine does not auto-reboot. -RenameMachine and -Remove do.


Usage

Provisioning a Forest Root DC

# Stage 1 — set password and rename, reboots automatically
.\setup.ps1 -LocalAdmin "P@ssw0rd!" -Rename "dc"

# Stage 2 — after reboot, configure network
.\setup.ps1 -IP 10.10.10.10 -DNS 10.10.10.10

# Stage 3 — install role
.\dc.ps1 -ADDS

# Stage 4 — promote to forest root, reboots automatically
.\dc.ps1 -NewDomain -DomainName "fortrix.lab" -DSRMPassword "DSRMPassw0rd!"

Provisioning a Child DC

# Stage 1 — set password and rename, reboots automatically
.\setup.ps1 -LocalAdmin "P@ssw0rd!" -Rename "us-dc"

# Stage 2 — after reboot, configure network (DNS points to forest root DC)
.\setup.ps1 -IP 10.10.20.10 -DNS 10.10.10.10

# Stage 3 — install role
.\dc.ps1 -ADDS

# Stage 4 — promote as child DC, reboots automatically
.\dc.ps1 -ChildDomain -DomainName "us" -ParentDomain "fortrix.lab" -DSRMPassword "DSRMPassw0rd!" -AdminUser "Administrator@fortrix.lab"

Provisioning a Workstation

# Stage 1 — set password and rename, reboots automatically
.\setup.ps1 -LocalAdmin "P@ssw0rd!" -Rename "ws"

# Stage 2 — after reboot, configure network (DNS points to DC)
.\setup.ps1 -IP 10.10.10.90 -DNS 10.10.10.10

# Stage 3 — join domain
.\ws.ps1 -JoinMachine "fortrix.lab" -AdminUser "Administrator@fortrix.lab"

# Stage 4 — reboot manually to apply domain join
Restart-Computer -Force

# Stage 5 — verify
.\ws.ps1 -Verify

Requirements

  • Windows Server 2025
  • PowerShell 5.1+
  • Elevated session (Run as Administrator)
  • AD RSAT installed for dc.ps1 and ws.ps1 (Install-WindowsFeature -Name RSAT-AD-PowerShell)

About

PowerShell scripts for automating Active Directory lab provisioning — machine setup, DC promotion, and domain join.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages