Merge pull request #222 from clong/configure_ou
Change order of configure-ou.ps1
This commit is contained in:
@@ -1,6 +1,19 @@
|
||||
# Purpose: Sets up the Server and Workstations OUs
|
||||
|
||||
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
|
||||
|
||||
Write-Host "Creating Server and Workstation OUs..."
|
||||
Write-Host "Creating Servers OU..."
|
||||
|
||||
if (!([ADSI]::Exists("LDAP://OU=Servers,DC=windomain,DC=local")))
|
||||
{
|
||||
New-ADOrganizationalUnit -Name "Servers" -Server "dc.windomain.local"
|
||||
@@ -9,6 +22,7 @@ else
|
||||
{
|
||||
Write-Host "Servers OU already exists. Moving On."
|
||||
}
|
||||
|
||||
Write-Host "Creating Workstations OU"
|
||||
if (!([ADSI]::Exists("LDAP://OU=Workstations,DC=windomain,DC=local")))
|
||||
{
|
||||
@@ -18,6 +32,7 @@ else
|
||||
{
|
||||
Write-Host "Workstations OU already exists. Moving On."
|
||||
}
|
||||
|
||||
# Sysprep breaks auto-login. Let's restore it here:
|
||||
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoAdminLogon -Value 1
|
||||
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultUserName -Value "vagrant"
|
||||
|
||||
@@ -4,7 +4,7 @@ $GPOName = 'Windows Event Forwarding Server'
|
||||
Import-GPO -BackupGpoName $GPOName -Path "c:\vagrant\resources\GPO\wef_configuration" -TargetName $GPOName -CreateIfNeeded
|
||||
$gpLinks = $null
|
||||
$OU = "OU=Servers,dc=windomain,dc=local"
|
||||
$gPLinks = Get-ADOrganizationalUnit -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
|
||||
$gPLinks = Get-ADOrganizationalUnit -Server "dc.windomain.local" -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
|
||||
$GPO = Get-GPO -Name $GPOName
|
||||
If ($gPLinks.LinkedGroupPolicyObjects -notcontains $gpo.path)
|
||||
{
|
||||
@@ -14,7 +14,7 @@ If ($gPLinks.LinkedGroupPolicyObjects -notcontains $gpo.path)
|
||||
}
|
||||
$OU = "ou=Domain Controllers,dc=windomain,dc=local"
|
||||
$gpLinks = $null
|
||||
$gPLinks = Get-ADOrganizationalUnit -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
|
||||
$gPLinks = Get-ADOrganizationalUnit -Server "dc.windomain.local" -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
|
||||
$GPO = Get-GPO -Name $GPOName
|
||||
If ($gPLinks.LinkedGroupPolicyObjects -notcontains $gpo.path)
|
||||
{
|
||||
@@ -24,7 +24,7 @@ If ($gPLinks.LinkedGroupPolicyObjects -notcontains $gpo.path)
|
||||
}
|
||||
$OU = "ou=Workstations,dc=windomain,dc=local"
|
||||
$gpLinks = $null
|
||||
$gPLinks = Get-ADOrganizationalUnit -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
|
||||
$gPLinks = Get-ADOrganizationalUnit -Server "dc.windomain.local" -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
|
||||
$GPO = Get-GPO -Name $GPOName
|
||||
If ($gPLinks.LinkedGroupPolicyObjects -notcontains $gpo.path)
|
||||
{
|
||||
@@ -39,7 +39,7 @@ $GPOName = 'Custom Event Channel Permissions'
|
||||
Import-GPO -BackupGpoName $GPOName -Path "c:\vagrant\resources\GPO\wef_configuration" -TargetName $GPOName -CreateIfNeeded
|
||||
$gpLinks = $null
|
||||
$OU = "OU=Servers,dc=windomain,dc=local"
|
||||
$gPLinks = Get-ADOrganizationalUnit -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
|
||||
$gPLinks = Get-ADOrganizationalUnit -Server "dc.windomain.local" -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
|
||||
$GPO = Get-GPO -Name $GPOName
|
||||
If ($gPLinks.LinkedGroupPolicyObjects -notcontains $gpo.path)
|
||||
{
|
||||
@@ -50,7 +50,7 @@ else
|
||||
Write-Host "GpLink $GPOName already linked on $OU. Moving On."
|
||||
}
|
||||
$OU = "ou=Domain Controllers,dc=windomain,dc=local"
|
||||
$gPLinks = Get-ADOrganizationalUnit -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
|
||||
$gPLinks = Get-ADOrganizationalUnit -Server "dc.windomain.local" -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
|
||||
$GPO = Get-GPO -Name $GPOName
|
||||
If ($gPLinks.LinkedGroupPolicyObjects -notcontains $gpo.path)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ else
|
||||
Write-Host "GpLink $GPOName already linked on $OU. Moving On."
|
||||
}
|
||||
$OU = "ou=Workstations,dc=windomain,dc=local"
|
||||
$gPLinks = Get-ADOrganizationalUnit -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
|
||||
$gPLinks = Get-ADOrganizationalUnit -Server "dc.windomain.local" -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
|
||||
$GPO = Get-GPO -Name $GPOName
|
||||
If ($gPLinks.LinkedGroupPolicyObjects -notcontains $gpo.path)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ if ((gwmi win32_computersystem).partofdomain -eq $false) {
|
||||
-SysvolPath "C:\Windows\SYSVOL" `
|
||||
-Force:$true
|
||||
|
||||
$newDNSServers = "8.8.8.8", "4.4.4.4"
|
||||
$newDNSServers = "127.0.0.1", "8.8.8.8", "4.4.4.4"
|
||||
$adapters = Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object { $_.IPAddress -And ($_.IPAddress).StartsWith($subnet) }
|
||||
if ($adapters) {
|
||||
Write-Host Setting DNS
|
||||
|
||||
Reference in New Issue
Block a user