Add a retry to configure-ou.ps1

This commit is contained in:
Chris Long
2020-06-13 22:35:15 -07:00
committed by GitHub
parent 5645cfcb45
commit 1dbe8a75b2

View File

@@ -20,6 +20,15 @@ try {
}
catch [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException] {
New-ADOrganizationalUnit -Name "Servers" -Server "dc.windomain.local"
Write-Host "Created Servers OU."
}
catch [Microsoft.ActiveDirectory.Management.ADServerDownException] {
Write-Host "Unable to reach Active Directory. Attmepting one more time..."
Start-Sleep 3
New-ADOrganizationalUnit -Name "Servers" -Server "dc.windomain.local"
}
catch {
Write-Host "Something went wrong attempting to reach AD or create the OU.
}
# Create the Workstations OU if it doesn't exist
@@ -30,6 +39,15 @@ try {
}
catch [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException] {
New-ADOrganizationalUnit -Name "Workstations" -Server "dc.windomain.local"
Write-Host "Created Workstations OU."
}
catch [Microsoft.ActiveDirectory.Management.ADServerDownException] {
Write-Host "Unable to reach Active Directory. Attmepting one more time..."
Start-Sleep 3
New-ADOrganizationalUnit -Name "Workstations" -Server "dc.windomain.local"
}
catch {
Write-Host "Something went wrong attempting to reach AD or create the OU.
}
# Sysprep breaks auto-login. Let's restore it here: