Convert ADSI:Exists to Get-ADOrganizationalUnit
This commit is contained in:
@@ -12,26 +12,25 @@ ping /n 1 dc.windomain.local
|
|||||||
ping /n 1 windomain.local
|
ping /n 1 windomain.local
|
||||||
|
|
||||||
Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) Creating Server and Workstation OUs..."
|
Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) Creating Server and Workstation OUs..."
|
||||||
Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) Creating Servers OU..."
|
# Create the Servers OU if it doesn't exist
|
||||||
|
Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) Creating Server OU"
|
||||||
if (!([ADSI]::Exists("LDAP://OU=Servers,DC=windomain,DC=local")))
|
try {
|
||||||
{
|
Get-ADOrganizationalUnit -Identity 'OU=Servers,DC=windomain,DC=local' | Out-Null
|
||||||
|
Write-Host "Servers OU already exists. Moving On."
|
||||||
|
}
|
||||||
|
catch [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException] {
|
||||||
New-ADOrganizationalUnit -Name "Servers" -Server "dc.windomain.local"
|
New-ADOrganizationalUnit -Name "Servers" -Server "dc.windomain.local"
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Write-Host "Servers OU already exists. Moving On."
|
|
||||||
}
|
|
||||||
|
|
||||||
|
# Create the Workstations OU if it doesn't exist
|
||||||
Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) Creating Workstations OU"
|
Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) Creating Workstations OU"
|
||||||
if (!([ADSI]::Exists("LDAP://OU=Workstations,DC=windomain,DC=local")))
|
try {
|
||||||
{
|
Get-ADOrganizationalUnit -Identity 'OU=Workstations,DC=windomain,DC=local' | Out-Null
|
||||||
New-ADOrganizationalUnit -Name "Workstations" -Server "dc.windomain.local"
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Write-Host "Workstations OU already exists. Moving On."
|
Write-Host "Workstations OU already exists. Moving On."
|
||||||
}
|
}
|
||||||
|
catch [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException] {
|
||||||
|
New-ADOrganizationalUnit -Name "Workstations" -Server "dc.windomain.local"
|
||||||
|
}
|
||||||
|
|
||||||
# Sysprep breaks auto-login. Let's restore it here:
|
# 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 AutoAdminLogon -Value 1
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ c:\windows\system32\tzutil.exe /s "UTC"
|
|||||||
|
|
||||||
Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) Disable IPv6 on all network adatpers..."
|
Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) Disable IPv6 on all network adatpers..."
|
||||||
Get-NetAdapterBinding -ComponentID ms_tcpip6 | ForEach-Object {Disable-NetAdapterBinding -Name $_.Name -ComponentID ms_tcpip6}
|
Get-NetAdapterBinding -ComponentID ms_tcpip6 | ForEach-Object {Disable-NetAdapterBinding -Name $_.Name -ComponentID ms_tcpip6}
|
||||||
|
Get-NetAdapterBinding -ComponentID ms_tcpip6
|
||||||
|
# https://support.microsoft.com/en-gb/help/929852/guidance-for-configuring-ipv6-in-windows-for-advanced-users
|
||||||
|
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters" /v DisabledComponents /t REG_DWORD /d 255 /f
|
||||||
|
|
||||||
if ($env:COMPUTERNAME -imatch 'vagrant') {
|
if ($env:COMPUTERNAME -imatch 'vagrant') {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user