From 659e33b454a220dfeae89e908e989c99e6222b04 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Fri, 16 Sep 2022 01:11:28 -0400 Subject: [PATCH] Retry domain join in a loop --- Set-ComputerName.ps1 | 23 ++++++++++++++++++++--- autounattend.xml | 2 +- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Set-ComputerName.ps1 b/Set-ComputerName.ps1 index 376f13b..eb91ad0 100755 --- a/Set-ComputerName.ps1 +++ b/Set-ComputerName.ps1 @@ -32,10 +32,27 @@ Write-Host "Waiting for RPC Service" # rename computer and join to domain Write-Host "Computer will be renamed to $NewComputerName." Rename-Computer -NewName $NewComputerName -Force -Verbose -Add-Computer -Force -DomainName sawtooth.claremontmakerspace.org -Options JoinWithNewName -Credential $cred -#Start-Sleep -Seconds 5 -#Restart-Computer + +Write-Host "Waiting for RPC Service" +(Get-Service RpcSs).WaitForStatus("Running") + +While($True){ + try{ + Write-Host "Trying to Domain Join" + Add-Computer -ErrorAction Stop -Force -DomainName sawtooth.claremontmakerspace.org -Options JoinWithNewName,InstallInvoke -Credential $cred + break + } + catch{ + Write-Host $_ + Start-Sleep -Seconds 1 # wait for a seconds before next attempt. + } +} # Install Salt # Write-Host "Installing Salt with minion name: $NewComputerName." # \\ucs\Software\Salt-Minion-2019.2.2-Py3-AMD64-Setup.exe /S /minion-name="$NewComputerName" + + +#Read-Host -Prompt "Press Enter to reboot" +#Start-Sleep -Seconds 30 +#Restart-Computer diff --git a/autounattend.xml b/autounattend.xml index e03baca..a59e4dd 100755 --- a/autounattend.xml +++ b/autounattend.xml @@ -159,7 +159,7 @@ - net use \\ucs\software /user:DomainJoin REPLACE_WITH_PASSWORD + net use \\ucs.sawtooth.claremontmakerspace.org\software /user:SAWTOOTH\Administrator REPLACE_WITH_PASSWORD Set Up UCS Share 1