Initial commit
This commit is contained in:
39
Packer/scripts/create-domain.ps1
Executable file
39
Packer/scripts/create-domain.ps1
Executable file
@@ -0,0 +1,39 @@
|
||||
if ((gwmi win32_computersystem).partofdomain -eq $false) {
|
||||
|
||||
Write-Host 'Creating domain controller'
|
||||
# Disable password complexity policy
|
||||
secedit /export /cfg C:\secpol.cfg
|
||||
(gc C:\secpol.cfg).replace("PasswordComplexity = 1", "PasswordComplexity = 0") | Out-File C:\secpol.cfg
|
||||
secedit /configure /db C:\Windows\security\local.sdb /cfg C:\secpol.cfg /areas SECURITYPOLICY
|
||||
rm -force C:\secpol.cfg -confirm:$false
|
||||
|
||||
# Set administrator password
|
||||
$computerName = $env:COMPUTERNAME
|
||||
$adminPassword = "vagrant"
|
||||
$adminUser = [ADSI] "WinNT://$computerName/Administrator,User"
|
||||
$adminUser.SetPassword($adminPassword)
|
||||
|
||||
$PlainPassword = "vagrant" # "P@ssw0rd"
|
||||
$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
|
||||
|
||||
# Windows Server 2012 R2
|
||||
Install-WindowsFeature AD-domain-services
|
||||
Import-Module ADDSDeployment
|
||||
Install-ADDSForest `
|
||||
-SafeModeAdministratorPassword $SecurePassword `
|
||||
-CreateDnsDelegation:$false `
|
||||
-DatabasePath "C:\Windows\NTDS" `
|
||||
-DomainMode "Win2012" `
|
||||
-DomainName "windomain.local" `
|
||||
-DomainNetbiosName "WINDOMAIN" `
|
||||
-ForestMode "Win2012" `
|
||||
-InstallDns:$true `
|
||||
-LogPath "C:\Windows\NTDS" `
|
||||
-NoRebootOnCompletion:$true `
|
||||
-SysvolPath "C:\Windows\SYSVOL" `
|
||||
-Force:$true
|
||||
|
||||
$newDNSServers = "8.8.8.8", "4.4.4.4"
|
||||
$adapters = Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.IPAddress -eq "10.0.2.15"}
|
||||
$adapters | ForEach-Object {$_.SetDNSServerSearchOrder($newDNSServers)}
|
||||
}
|
||||
Reference in New Issue
Block a user