Phase 5: AD role scripts, WinRM provisioning and lab wordlist
dc01 promotes the forest then runs a startup-scheduled post stage for OUs, users, groups, the SPN on svc_backup, pre-auth disabled on j.contractor, GenericAll over t.smith, the www A record, flags and advanced audit policy. fs01 installs IIS, shares the web root's public/ as \\FS01\Public and joins. ws01 joins, then adds WS Admins to local Administrators. provision uploads over WinRM, starts scripts detached, waits on a .done marker and survives the promotion reboot.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
# Norbourg lab — shared helpers for role scripts.
|
||||
# Every role script writes a "<script>.done" marker so the host can wait
|
||||
# without parsing output, and so a failure is visible instead of silent.
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
|
||||
function Get-LabBase { 'C:\norbourg' }
|
||||
|
||||
function Write-LabLog {
|
||||
param([string]$Message)
|
||||
$line = "{0} {1}" -f (Get-Date -Format 'HH:mm:ss'), $Message
|
||||
Write-Host $line
|
||||
Add-Content -Path (Join-Path (Get-LabBase) 'provision.log') -Value $line
|
||||
}
|
||||
|
||||
function Complete-Stage {
|
||||
param([string]$Path, [string]$Message = 'ok')
|
||||
Set-Content -Path "$Path.done" -Value $Message -Encoding ascii
|
||||
Write-LabLog "stage done: $Message"
|
||||
}
|
||||
|
||||
function Fail-Stage {
|
||||
param([string]$Path, [string]$Message)
|
||||
Set-Content -Path "$Path.done" -Value "FAIL $Message" -Encoding ascii
|
||||
Write-LabLog "stage failed: $Message"
|
||||
throw $Message
|
||||
}
|
||||
|
||||
function Wait-ForDomain {
|
||||
param([int]$TimeoutSeconds = 600)
|
||||
$deadline = (Get-Date).AddSeconds($TimeoutSeconds)
|
||||
while ((Get-Date) -lt $deadline) {
|
||||
try {
|
||||
$null = Get-ADDomain -ErrorAction Stop
|
||||
return
|
||||
} catch {
|
||||
Start-Sleep -Seconds 10
|
||||
}
|
||||
}
|
||||
throw 'domain services did not come up in time'
|
||||
}
|
||||
Reference in New Issue
Block a user