Retry domain join in a loop

This commit is contained in:
Adam Goldsmith 2022-09-16 01:11:28 -04:00
parent c309393ebc
commit 659e33b454
2 changed files with 21 additions and 4 deletions

View File

@ -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

View File

@ -159,7 +159,7 @@
</AutoLogon>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<CommandLine>net use \\ucs\software /user:DomainJoin REPLACE_WITH_PASSWORD</CommandLine>
<CommandLine>net use \\ucs.sawtooth.claremontmakerspace.org\software /user:SAWTOOTH\Administrator REPLACE_WITH_PASSWORD</CommandLine>
<Description>Set Up UCS Share</Description>
<Order>1</Order>
</SynchronousCommand>