-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprovision-domain-controller-create.ps1
More file actions
39 lines (33 loc) · 1.47 KB
/
Copy pathprovision-domain-controller-create.ps1
File metadata and controls
39 lines (33 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
param(
$domain = 'example.test'
)
$netbiosDomain = ($domain -split '\.')[0].ToUpperInvariant()
$safeModeAdminstratorPassword = ConvertTo-SecureString 'HeyH0Password' -AsPlainText -Force
# make sure the Administrator has a password that meets the minimum Windows
# password complexity requirements (otherwise the AD will refuse to install).
Write-Output 'Resetting the Administrator account password and settings...'
Set-LocalUser `
-Name Administrator `
-AccountNeverExpires `
-Password $safeModeAdminstratorPassword `
-PasswordNeverExpires:$true `
-UserMayChangePassword:$true
Write-Output 'Disabling the Administrator account (we only use the vagrant account)...'
Disable-LocalUser `
-Name Administrator
Write-Output 'Installing the AD services and administration tools...'
Install-WindowsFeature AD-Domain-Services,RSAT-AD-AdminCenter,RSAT-ADDS-Tools
Write-Output 'Installing the AD forest (be patient, this will take more than 30m to install)...'
Import-Module ADDSDeployment
# NB ForestMode and DomainMode are set to WinThreshold (Windows Server 2016).
# see https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/active-directory-functional-levels
Install-ADDSForest `
-InstallDns `
-CreateDnsDelegation:$false `
-ForestMode 'WinThreshold' `
-DomainMode 'WinThreshold' `
-DomainName $domain `
-DomainNetbiosName $netbiosDomain `
-SafeModeAdministratorPassword $safeModeAdminstratorPassword `
-NoRebootOnCompletion `
-Force