Update configure-ou.ps1

This commit is contained in:
Chris Long
2019-03-25 08:13:44 +07:00
committed by GitHub
parent 03b0c894d0
commit f656b82db4

View File

@@ -4,6 +4,9 @@ Write-Host "Checking AD services status..."
$svcs = "adws","dns","kdc","netlogon"
Get-Service -name $svcs -ComputerName localhost | Select Machinename,Name,Status
# Hardcoding DC hostname in hosts file
Add-Content "c:\windows\system32\drivers\etc\hosts" " 192.168.38.102 dc.windomain.local"
# Force DNS resolution of the domain
ping /n 1 dc.windomain.local
ping /n 1 windomain.local
@@ -11,31 +14,23 @@ ping /n 1 windomain.local
Write-Host "Creating Server and Workstation OUs..."
Write-Host "Creating Servers OU..."
try {
if (!([ADSI]::Exists("LDAP://OU=Servers,DC=windomain,DC=local")))
{
if (!([ADSI]::Exists("LDAP://OU=Servers,DC=windomain,DC=local")))
{
New-ADOrganizationalUnit -Name "Servers" -Server "dc.windomain.local"
}
else
{
}
else
{
Write-Host "Servers OU already exists. Moving On."
}
} catch {
New-ADOrganizationalUnit -Name "Servers" -Server "dc.windomain.local"
}
Write-Host "Creating Workstations OU"
try {
if (!([ADSI]::Exists("LDAP://OU=Workstations,DC=windomain,DC=local")))
{
if (!([ADSI]::Exists("LDAP://OU=Workstations,DC=windomain,DC=local")))
{
New-ADOrganizationalUnit -Name "Workstations" -Server "dc.windomain.local"
}
else
{
}
else
{
Write-Host "Workstations OU already exists. Moving On."
}
} catch {
New-ADOrganizationalUnit -Name "Workstations" -Server "dc.windomain.local"
}
# Sysprep breaks auto-login. Let's restore it here: