From c735f529347195b7370a90982b73f97cabd1902a Mon Sep 17 00:00:00 2001 From: Chris Long Date: Sun, 21 Jun 2020 11:49:18 -0700 Subject: [PATCH] Fixing the loop logic --- Vagrant/scripts/configure-ou.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Vagrant/scripts/configure-ou.ps1 b/Vagrant/scripts/configure-ou.ps1 index f75d8b2..7abb08d 100644 --- a/Vagrant/scripts/configure-ou.ps1 +++ b/Vagrant/scripts/configure-ou.ps1 @@ -19,6 +19,7 @@ while ($servers_ou_created -ne 1) { try { Get-ADOrganizationalUnit -Identity 'OU=Servers,DC=windomain,DC=local' | Out-Null Write-Host "Servers OU already exists. Moving On." + $servers_ou_created = 1 } catch [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException] { New-ADOrganizationalUnit -Name "Servers" -Server "dc.windomain.local" @@ -41,10 +42,12 @@ Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) Creating Workstations OU" try { Get-ADOrganizationalUnit -Identity 'OU=Workstations,DC=windomain,DC=local' | Out-Null Write-Host "Workstations OU already exists. Moving On." + $workstations_ou_created = 1 } catch [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException] { New-ADOrganizationalUnit -Name "Workstations" -Server "dc.windomain.local" Write-Host "Created Workstations OU." + $workstations_ou_created = 1 } catch [Microsoft.ActiveDirectory.Management.ADServerDownException] { Write-Host "Unable to reach Active Directory. Sleeping for 5 and trying again..."