Provisioning fixes: auth-based readiness, domain join guards, site push
- wait for WinRM with an authenticated call, not a TCP probe: the port opens before the service can authenticate - skip promotion/join when the machine is already there, so provision is idempotent - probe the domain with System.DirectoryServices: Get-ADDomain needs RSAT, which a member server does not have - passwords must not contain the account name (Legault2024! is rejected) - Web-Dir-Browsing is the real feature name - push the site over SMB from C$: WinRM caps the command line at 8 KB
This commit is contained in:
+6
-10
@@ -8,6 +8,12 @@ $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'
|
||||
@@ -16,14 +22,6 @@ try {
|
||||
Write-LabLog 'dc01: AD-Domain-Services already installed'
|
||||
}
|
||||
|
||||
$post = Join-Path $PSScriptRoot 'dc01-post.ps1'
|
||||
if (-not (Test-Path $post)) { Fail-Stage $self 'dc01-post.ps1 missing next to dc01.ps1' }
|
||||
|
||||
# Run the account/ACL stage once, at next startup, as SYSTEM.
|
||||
$null = schtasks.exe /Create /TN 'NorbourgDcPost' /F /SC ONSTART /RU SYSTEM /RL HIGHEST `
|
||||
/TR "powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"$post`""
|
||||
Write-LabLog 'dc01: scheduled dc01-post.ps1 at startup'
|
||||
|
||||
$safeMode = ConvertTo-SecureString '@@SAFE_MODE_PASSWORD@@' -AsPlainText -Force
|
||||
|
||||
Write-LabLog 'dc01: creating forest norbourg.lab'
|
||||
@@ -32,8 +30,6 @@ try {
|
||||
-DomainNetbiosName '@@NETBIOS@@' `
|
||||
-InstallDns `
|
||||
-SafeModeAdministratorPassword $safeMode `
|
||||
-ForestMode WinThreshold `
|
||||
-DomainMode WinThreshold `
|
||||
-NoRebootOnCompletion `
|
||||
-Force
|
||||
|
||||
|
||||
Reference in New Issue
Block a user