-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateADDC2.ps1
105 lines (90 loc) · 2.81 KB
/
CreateADDC2.ps1
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
configuration CreateADDC2
{
param
(
[Parameter(Mandatory)]
[String]$DomainName,
[Parameter(Mandatory)]
[System.Management.Automation.PSCredential]$Admincreds,
[Int]$RetryCount=20,
[Int]$RetryIntervalSec=30
)
Import-DscResource -ModuleName xActiveDirectory, xStorage, xNetworking, PSDesiredStateConfiguration, xPendingReboot
[System.Management.Automation.PSCredential ]$DomainCreds = New-Object System.Management.Automation.PSCredential ("${DomainName}\$($Admincreds.UserName)", $Admincreds.Password)
$Interface=Get-NetAdapter|Where Name -Like "Ethernet*"|Select-Object -First 1
$InterfaceAlias=$($Interface.Name)
Node localhost
{
LocalConfigurationManager
{
RebootNodeIfNeeded = $true
}
WindowsFeature DNS
{
Ensure = "Present"
Name = "DNS"
}
Script EnableDNSDiags
{
SetScript = {
Set-DnsServerDiagnostics -All $true
Write-Verbose -Verbose "Enabling DNS client diagnostics"
}
GetScript = { @{} }
TestScript = { $false }
DependsOn = "[WindowsFeature]DNS"
}
WindowsFeature DnsTools
{
Ensure = "Present"
Name = "RSAT-DNS-Server"
DependsOn = "[WindowsFeature]DNS"
}
xDnsServerAddress DnsServerAddress
{
Address = '192.168.1.133'
InterfaceAlias = $InterfaceAlias
AddressFamily = 'IPv4'
DependsOn = "[WindowsFeature]DNS"
}
xWaitforDisk Disk2
{
DiskId = 2
RetryIntervalSec =$RetryIntervalSec
RetryCount = $RetryCount
}
xDisk ADDataDisk {
DiskId = 2
DriveLetter = "F"
DependsOn = "[xWaitForDisk]Disk2"
}
WindowsFeature ADDSInstall
{
Ensure = "Present"
Name = "AD-Domain-Services"
DependsOn="[WindowsFeature]DNS"
}
WindowsFeature ADDSTools
{
Ensure = "Present"
Name = "RSAT-ADDS-Tools"
DependsOn = "[WindowsFeature]ADDSInstall"
}
WindowsFeature ADAdminCenter
{
Ensure = "Present"
Name = "RSAT-AD-AdminCenter"
DependsOn = "[WindowsFeature]ADDSInstall"
}
xADDomainController SecondDC
{
DomainName = $DomainName
DomainAdministratorCredential = $DomainCreds
SafemodeAdministratorPassword = $DomainCreds
DatabasePath = "F:\NTDS"
LogPath = "F:\NTDS"
SysvolPath = "F:\SYSVOL"
DependsOn = @("[xDisk]ADDataDisk", "[WindowsFeature]ADDSInstall")
}
}
}