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.
30 lines
1.0 KiB
PowerShell
30 lines
1.0 KiB
PowerShell
# Norbourg lab — WS01: domain-joined workstation.
|
|
# Stage 2 runs after the join reboot because local group membership needs the
|
|
# domain group to resolve.
|
|
|
|
. "$PSScriptRoot\..\lib\common.ps1"
|
|
|
|
$self = $PSCommandPath
|
|
Write-LabLog 'ws01: starting'
|
|
|
|
try {
|
|
$post = Join-Path $PSScriptRoot 'ws01-post.ps1'
|
|
if (-not (Test-Path $post)) { Fail-Stage $self 'ws01-post.ps1 missing' }
|
|
|
|
$null = schtasks.exe /Create /TN 'NorbourgWsPost' /F /SC ONSTART /RU SYSTEM /RL HIGHEST `
|
|
/TR "powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"$post`""
|
|
|
|
$cred = New-Object System.Management.Automation.PSCredential(
|
|
'@@DOMAIN@@\Administrator',
|
|
(ConvertTo-SecureString '@@ADMIN_PASSWORD@@' -AsPlainText -Force))
|
|
|
|
Write-LabLog 'ws01: joining the domain'
|
|
Add-Computer -DomainName '@@DOMAIN@@' -Credential $cred `
|
|
-OUPath 'OU=Ordinateurs,OU=Norbourg,@@BASE_DN@@' -Force
|
|
|
|
Complete-Stage $self 'ok reboot'
|
|
Restart-Computer -Force
|
|
} catch {
|
|
Fail-Stage $self $_.Exception.Message
|
|
}
|