# 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 }