PowerShell scripts for provisioning Active Directory lab environments. Covers initial machine setup, Domain Controller promotion, and workstation domain management.
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.
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) |
-Renametriggers an immediate reboot.-LocalAdminand-Renamemust be run separately from-IPand-DNS— the reboot kills the session before network config can execute.
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) |
-NewDomainand-ChildDomainboth trigger an automatic reboot on completion.
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 |
-JoinMachinedoes not auto-reboot.-RenameMachineand-Removedo.
# 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!"# 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"# 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- Windows Server 2025
- PowerShell 5.1+
- Elevated session (
Run as Administrator) - AD RSAT installed for
dc.ps1andws.ps1(Install-WindowsFeature -Name RSAT-AD-PowerShell)