Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.

Commit 4714a05

Browse files
v4.8.0
1 parent dd85a3e commit 4714a05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3016
-2032
lines changed

Configurations/Implement-Windows-Server-DHCP-2016/Instructions.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,31 @@
22

33
This lab is specifically designed for the Implementing Windows Server 2016 DHCP from Pluralsight.com. It will provide a fully-function AD environment using company.pri for a domain, and it builds the following servers:
44

5-
* 1 DC
6-
* 1 Server (s1)
7-
* 2 Clients with RSAT (Cli1,Cli2)
8-
9-
*## To get started
5+
Computername : DC1
6+
Description : Windows Server 2016 Standard Core 64bit English Evaluation
7+
Role : {DC}
8+
IPAddress : 192.168.3.10
9+
MemoryGB : 2
10+
11+
Computername : S1
12+
Description : Windows Server 2016 Standard Core 64bit English Evaluation
13+
Role : {DomainJoin}
14+
IPAddress : 192.168.3.50
15+
MemoryGB : 1
16+
17+
Computername : Cli1
18+
Description : Windows 10 64bit Enterprise 1903 English Evaluation
19+
Role : {domainJoin, RSAT, RDP}
20+
IPAddress : 192.168.3.100
21+
MemoryGB : 2
22+
23+
Computername : Cli2
24+
Description : Windows 10 64bit Enterprise 1903 English Evaluation
25+
Role : {domainJoin, RDP}
26+
IPAddress : 192.168.3.101
27+
MemoryGB : 2
28+
29+
## To get started
1030

1131
To run the full lab setup, which includes Setup-Lab, Run-Lab, Enable-Internet, and Validate-Lab:
1232
PS> Unattend-Lab
@@ -19,18 +39,18 @@ This lab is specifically designed for the Implementing Windows Server 2016 DHCP
1939
To start the Lab, and apply configurations the first time:
2040
PS> Run-Lab
2141

22-
To enable Internet access for the VM's, run:
42+
To enable Internet access for the VMs, run:
2343
PS> Enable-Internet
2444

2545
To validate when configurations have converged:
2646
PS> Validate-Lab
2747

2848
## To Stop and snapshot the lab
2949

30-
To stop the lab VM's:
50+
To stop the lab VMs:
3151
PS> Shutdown-lab
3252

33-
To checkpoint the VM's:
53+
To checkpoint the VMs:
3454
PS> Snapshot-Lab
3555

3656
To quickly rebuild the labs from the checkpoint, run:

Configurations/Implement-Windows-Server-DHCP-2016/VMValidate.test.ps1

Lines changed: 172 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -12,129 +12,212 @@ $cred = New-Object PSCredential "Company\Administrator", $Secure
1212
$all = @()
1313
Describe DC1 {
1414

15-
$dc = New-PSSession -VMName DC1 -Credential $cred -ErrorAction SilentlyContinue
16-
$all += $dc
17-
#set error action preference to suppress all error messsages
18-
Invoke-Command { $errorActionPreference = 'silentlyContinue'} -session $dc
15+
Try {
16+
$dc = New-PSSession -VMName DC1 -Credential $cred -ErrorAction Stop
17+
$all += $dc
1918

20-
It "[DC1] Should accept domain admin credential" {
21-
$dc.Count | Should Be 1
22-
}
19+
#set error action preference to suppress all error messsages
20+
Invoke-Command { $errorActionPreference = 'silentlyContinue'} -session $dc
2321

24-
#test for features
25-
$feat = Invoke-Command { Get-WindowsFeature | Where-Object installed} -session $dc
26-
$needed = 'AD-Domain-Services', 'DNS', 'RSAT-AD-Tools',
27-
'RSAT-AD-PowerShell'
28-
foreach ($item in $needed) {
29-
It "[DC1] Should have feature $item installed" {
30-
$feat.Name -contains $item | Should Be "True"
22+
It "[DC1] Should accept domain admin credential" {
23+
$dc.Count | Should Be 1
3124
}
32-
}
3325

34-
It "[DC1] Should have an IP address of 192.168.3.10" {
35-
$i = Invoke-command -ScriptBlock { Get-NetIPAddress -interfacealias 'Ethernet' -AddressFamily IPv4} -Session $dc
36-
$i.ipv4Address | should be '192.168.3.10'
37-
}
26+
#test for features
27+
$feat = Invoke-Command { Get-WindowsFeature | Where-Object installed} -session $dc
28+
$needed = 'AD-Domain-Services', 'DNS', 'RSAT-AD-Tools',
29+
'RSAT-AD-PowerShell'
30+
foreach ($item in $needed) {
31+
It "[DC1] Should have feature $item installed" {
32+
$feat.Name -contains $item | Should Be "True"
33+
}
34+
}
3835

39-
It "[DC1] Should have a domain name of $domain" {
40-
$r = Invoke-command { Get-ADDomain -ErrorAction SilentlyContinue } -session $dc
41-
$r.name | should Be $domain
42-
}
36+
It "[DC1] Should have an IP address of 192.168.3.10" {
37+
$i = Invoke-Command -ScriptBlock { Get-NetIPAddress -interfacealias 'Ethernet' -AddressFamily IPv4} -Session $dc
38+
$i.ipv4Address | Should be '192.168.3.10'
39+
}
4340

44-
$OUs = Invoke-command { Get-ADorganizationalUnit -filter * -ErrorAction SilentlyContinue} -session $dc
45-
$needed = 'IT', 'Dev', 'Marketing', 'Sales', 'Accounting', 'JEA_Operators'
46-
foreach ($item in $needed) {
47-
It "[DC1] Should have organizational unit $item" {
48-
$OUs.name -contains $item | Should Be "True"
41+
It "[DC1] Should have a domain name of $domain" {
42+
$r = Invoke-Command {
43+
Try {
44+
Get-ADDomain -ErrorAction Stop
45+
}
46+
Catch {
47+
#ignore the error - Domain still spinning up
48+
}
49+
} -session $dc
50+
$r.name | Should Be $domain
4951
}
50-
}
51-
$groups = Invoke-Command { Get-ADGroup -filter * -ErrorAction SilentlyContinue} -session $DC
52-
$target = "IT", "Sales", "Marketing", "Accounting", "JEA Operators"
53-
foreach ($item in $target) {
5452

55-
It "[DC1] Should have a group called $item" {
56-
$groups.Name -contains $item | Should Be "True"
53+
$OUs = Invoke-Command {
54+
Try {
55+
Get-ADOrganizationalUnit -filter * -ErrorAction Stop
56+
}
57+
Catch {
58+
#ignore the error - Domain still spinning up
59+
}
60+
} -session $dc
61+
62+
$needed = 'IT', 'Dev', 'Marketing', 'Sales', 'Accounting', 'JEA_Operators'
63+
foreach ($item in $needed) {
64+
It "[DC1] Should have organizational unit $item" {
65+
$OUs.name -contains $item | Should Be "True"
66+
}
5767
}
5868

59-
}
69+
$groups = Invoke-Command {
70+
Try {
71+
Get-ADGroup -filter * -ErrorAction Stop
72+
}
73+
Catch {
74+
#ignore the error - Domain still spinning up
75+
}
76+
} -session $DC
77+
78+
$target = "IT", "Sales", "Marketing", "Accounting", "JEA Operators"
79+
foreach ($item in $target) {
80+
81+
It "[DC1] Should have a group called $item" {
82+
$groups.Name -contains $item | Should Be "True"
83+
}
84+
}
6085

61-
$users = Invoke-Command { Get-AdUser -filter * -ErrorAction SilentlyContinue} -session $dc
62-
It "[DC1] Should have at least 15 user accounts" {
63-
$users.count | should BeGreaterThan 15
64-
}
86+
$users = Invoke-Command {
87+
Try {
88+
Get-ADUser -filter * -ErrorAction Stop
89+
}
90+
Catch {
91+
#ignore the error - Domain still spinning up
92+
}
93+
} -session $dc
94+
95+
It "[DC1] Should have at least 15 user accounts" {
96+
$users.count | Should BeGreaterThan 15
97+
}
6598

66-
$computer = Invoke-Command { Get-ADComputer -filter * -ErrorAction SilentlyContinue} -session $dc
67-
It "[DC1] Should have a computer account for Cli1" {
68-
$computer.name -contains "cli1" | Should Be "True"
69-
}
99+
$computer = Invoke-Command {
100+
Try {
101+
Get-ADComputer -filter * -ErrorAction SilentlyContinue
102+
}
103+
Catch {
104+
#ignore the error - Domain still spinning up
105+
}
106+
} -session $dc
107+
108+
It "[DC1] Should have a computer account for Cli1" {
109+
$computer.name -contains "cli1" | Should Be "True"
110+
}
70111

71-
It "[DC1] Should have a computer account for Cli2" {
72-
$computer.name -contains "cli2" | Should Be "True"
112+
It "[DC1] Should have a computer account for Cli2" {
113+
$computer.name -contains "cli2" | Should Be "True"
114+
}
115+
It "[DC1] Should have a computer account for S1" {
116+
$computer.name -contains "S1" | Should Be "True"
117+
}
73118
}
74-
It "[DC1] Should have a computer account for S1" {
75-
$computer.name -contains "S1" | Should Be "True"
119+
Catch {
120+
It "[DC1] Should allow a PSSession" {
121+
$false | Should Be $True
122+
}
76123
}
77-
78124
} #DC
79125

80126
Describe S1 {
81-
$s1 = New-PSSession -VMName S1 -Credential $cred -ErrorAction SilentlyContinue
82-
$all += $s1
83-
It "[S1] Should accept domain admin credential" {
84-
$s1.Count | Should Be 1
85-
}
127+
Try {
128+
129+
$s1 = New-PSSession -VMName S1 -Credential $cred -ErrorAction Stop
130+
$all += $s1
86131

87-
It "[S1] Should have an IP address of 192.168.3.50" {
88-
$i = Invoke-command -ScriptBlock { Get-NetIPAddress -interfacealias 'Ethernet' -AddressFamily IPv4} -Session $S1
89-
$i.ipv4Address | should be '192.168.3.50'
132+
#set error action preference to suppress all error messsages
133+
Invoke-Command { $errorActionPreference = 'silentlyContinue'} -session $s1
134+
135+
It "[S1] Should accept domain admin credential" {
136+
$s1.Count | Should Be 1
137+
}
138+
139+
It "[S1] Should have an IP address of 192.168.3.50" {
140+
$i = Invoke-Command -ScriptBlock { Get-NetIPAddress -interfacealias 'Ethernet' -AddressFamily IPv4} -Session $S1
141+
$i.ipv4Address | Should be '192.168.3.50'
142+
}
143+
$dns = Invoke-Command {Get-DnsClientServerAddress -InterfaceAlias ethernet -AddressFamily IPv4} -session $s1
144+
It "[S1] Should have a DNS server configuration of 192.168.3.10" {
145+
$dns.ServerAddresses -contains '192.168.3.10' | Should Be "True"
146+
}
90147
}
91-
$dns = Invoke-Command {Get-DnsClientServerAddress -InterfaceAlias ethernet -AddressFamily IPv4} -session $s1
92-
It "[S1] Should have a DNS server configuration of 192.168.3.10" {
93-
$dns.ServerAddresses -contains '192.168.3.10' | Should Be "True"
148+
Catch {
149+
It "[S1] Should allow a PSSession" {
150+
$false | Should Be $True
151+
}
94152
}
95-
96153
} #S1
97154

98155
Describe Cli1 {
99156

100-
$cl = New-PSSession -VMName cli1 -Credential $cred -ErrorAction SilentlyContinue
101-
$all += $cl
102-
It "[CLI] Should accept domain admin credential" {
103-
$cl = New-PSSession -VMName cli1 -Credential $cred -ErrorAction SilentlyContinue
104-
$cl.Count | Should Be 1
105-
}
157+
Try {
106158

107-
It "[CLI] Should have an IP address of 192.168.3.100" {
108-
$i = Invoke-command -ScriptBlock { Get-NetIPAddress -interfacealias 'Ethernet' -AddressFamily IPv4} -session $cl
109-
$i.ipv4Address | should be '192.168.3.100'
110-
}
159+
$cl = New-PSSession -VMName cli1 -Credential $cred -ErrorAction Stop
160+
$all += $cl
111161

112-
$dns = Invoke-Command {Get-DnsClientServerAddress -InterfaceAlias ethernet -AddressFamily IPv4} -session $cl
113-
It "[CLI] Should have a DNS server configuration of 192.168.3.10" {
114-
$dns.ServerAddresses -contains '192.168.3.10' | Should Be "True"
115-
}
162+
#set error action preference to suppress all error messsages
163+
Invoke-Command { $errorActionPreference = 'silentlyContinue'} -session $cl
116164

165+
It "[CLI1]] Should accept domain admin credential" {
166+
$cl.Count | Should Be 1
167+
}
168+
169+
It "[CLI1]] Should have an IP address of 192.168.3.100" {
170+
$i = Invoke-Command -ScriptBlock { Get-NetIPAddress -interfacealias 'Ethernet' -AddressFamily IPv4} -session $cl
171+
$i.ipv4Address | Should be '192.168.3.100'
172+
}
173+
174+
It "[CLI1]] Should have RSAT installed" {
175+
$pkg = Invoke-Command {Get-WindowsCapability -online -name *rsat*} -session $cl
176+
177+
# write-host ($pkg | Select-object Name,Displayname,State | format-list | Out-String) -ForegroundColor cyan
178+
$pkg | Where-Object { $_.state -ne "installed"} | Should be $Null
179+
}
180+
181+
$dns = Invoke-Command {Get-DnsClientServerAddress -InterfaceAlias ethernet -AddressFamily IPv4} -session $cl
182+
It "[CLI1]] Should have a DNS server configuration of 192.168.3.10" {
183+
$dns.ServerAddresses -contains '192.168.3.10' | Should Be "True"
184+
}
185+
}
186+
Catch {
187+
It "[CLI1] Should allow a PSSession" {
188+
$false | Should Be $True
189+
}
190+
}
117191
} #cli1
118192

119193
Describe Cli2 {
120194

121-
$cl2 = New-PSSession -VMName cli2 -Credential $cred -ErrorAction SilentlyContinue
122-
$all += $cl2
123-
It "[CLI2] Should accept domain admin credential" {
124-
$cl2 = New-PSSession -VMName cli1 -Credential $cred -ErrorAction SilentlyContinue
125-
$cl2.Count | Should Be 1
126-
}
195+
Try {
127196

128-
It "[CLI2] Should have an IP address of 192.168.3.101" {
129-
$i = Invoke-command -ScriptBlock { Get-NetIPAddress -interfacealias 'Ethernet' -AddressFamily IPv4} -session $cl2
130-
$i.ipv4Address | should be '192.168.3.101'
131-
}
197+
$cl2 = New-PSSession -VMName cli2 -Credential $cred -ErrorAction Stop
198+
$all += $cl2
132199

133-
$dns = Invoke-Command {Get-DnsClientServerAddress -InterfaceAlias ethernet -AddressFamily IPv4} -session $cl2
134-
It "[CLI2] Should have a DNS server configuration of 192.168.3.101" {
135-
$dns.ServerAddresses -contains '192.168.3.10' | Should Be "True"
136-
}
200+
#set error action preference to suppress all error messsages
201+
Invoke-Command { $errorActionPreference = 'silentlyContinue'} -session $cl2
202+
It "[CLI2] Should accept domain admin credential" {
203+
$cl2.Count | Should Be 1
204+
}
137205

206+
It "[CLI2] Should have an IP address of 192.168.3.101" {
207+
$i = Invoke-Command -ScriptBlock { Get-NetIPAddress -interfacealias 'Ethernet' -AddressFamily IPv4} -session $cl2
208+
$i.ipv4Address | Should be '192.168.3.101'
209+
}
210+
211+
$dns = Invoke-Command {Get-DnsClientServerAddress -InterfaceAlias ethernet -AddressFamily IPv4} -session $cl2
212+
It "[CLI2] Should have a DNS server configuration of 192.168.3.101" {
213+
$dns.ServerAddresses -contains '192.168.3.10' | Should Be "True"
214+
}
215+
}
216+
Catch {
217+
It "[CLI2] Should allow a PSSession" {
218+
$false | Should Be $True
219+
}
220+
}
138221
} #cli2
139222

140-
$all| Remove-PSSession
223+
$all | Remove-PSSession

0 commit comments

Comments
 (0)