Files
pentest.intro/session1/content/windows/roles/dc01.ps1
T
quoije dcb64ac65e Restructure the repository per session
session1/ now holds the whole live lab (content, platforms, docs, answer key,
README); session2/ keeps the design for the second workshop. The root README
indexes both and states that session2 modifies session1 rather than
duplicating it.

build-bundle.sh builds from session1 and still produces a flat archive, so
the documented paths inside a deployment (platforms/<p>/lab.sh) are
unchanged. .gitignore follows the move.
2026-10-24 14:22:39 -04:00

41 lines
1.3 KiB
PowerShell

# Norbourg lab — DC01 stage 1: install AD DS and create the forest.
# Promotion reboots the machine, so the account/ACL work lives in dc01-post.ps1
# and is scheduled as a startup task before the reboot.
. "$PSScriptRoot\..\lib\common.ps1"
$self = $PSCommandPath
Write-LabLog 'dc01: stage 1 starting'
try {
# Re-running provision must not try to promote a server that already is one.
if ((Get-Service NTDS -ErrorAction SilentlyContinue).Status -eq 'Running') {
Complete-Stage $self 'ok already-dc'
return
}
$feature = Get-WindowsFeature -Name AD-Domain-Services
if (-not $feature.Installed) {
Write-LabLog 'dc01: installing AD-Domain-Services'
$null = Install-WindowsFeature -Name AD-Domain-Services -IncludeManagementTools
} else {
Write-LabLog 'dc01: AD-Domain-Services already installed'
}
$safeMode = ConvertTo-SecureString '@@SAFE_MODE_PASSWORD@@' -AsPlainText -Force
Write-LabLog 'dc01: creating forest norbourg.lab'
$null = Install-ADDSForest `
-DomainName '@@DOMAIN@@' `
-DomainNetbiosName '@@NETBIOS@@' `
-InstallDns `
-SafeModeAdministratorPassword $safeMode `
-NoRebootOnCompletion `
-Force
Complete-Stage $self 'ok reboot'
Restart-Computer -Force
} catch {
Fail-Stage $self $_.Exception.Message
}