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

Commit 0994fbf

Browse files
v4.9.0
1 parent ee78d4d commit 0994fbf

18 files changed

+1050
-321
lines changed

Authoring-FAQ.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Authoring FAQ
2+
3+
This guide is intended for people who are creating their own lab configurations.If you want to do so, the best approach is to make a copy of a configuration folder that is closest to what you want and then modify those files.
4+
5+
**It is not recommended to attempt to author your own configuration without solid PowerShell, Desired State Configuration and Hyper-V experience.**
6+
7+
## How do I specify a different operating system
8+
9+
First, find the node information in the VMConfigurationData.psd1 file.
10+
11+
```powershell
12+
@{
13+
NodeName = 'S1'
14+
IPAddress = '192.168.3.50'
15+
#Role = 'DomainJoin' # example of multiple roles @('DomainJoin', 'Web')
16+
Role = @('DomainJoin', 'Web')
17+
Lability_BootOrder = 20
18+
Lability_timeZone = 'US Mountain Standard Time' #[System.TimeZoneInfo]::GetSystemTimeZones()
19+
Lability_Media = '2019_x64_Standard_EN_Core_Eval'
20+
}
21+
```
22+
23+
You will need to change the `Lability_Media` section. At a PowerShell prompt run `Get-LabMedia`. Copy the appropriate ID and replace the `Lability_Media` value. The first time you build the configuration with new media, the corresponding ISO file will be downloaded.
24+
25+
## I'm getting an error when my VM is booting for the first time
26+
27+
Full error: *Windows could not parse or process the unattend answer file [C:\Windows\system32\sysprep\unattend.xml] for pass [specialize]. The answer file is invalid.*
28+
29+
Make sure that the configuration changes you've made are valid. Specifically, this error is known to be caused by an invalid NodeName. NodeName on Windows must match the rules for a Windows Computer Name, notably a 15 character maximum. See details here: https://support.microsoft.com/en-us/kb/909264
30+
31+
## How can I avoid issues when changing VM names
32+
33+
Use `Wipe-Lab` before changing names (i.e `NodeName` or `EnvironmentPrefix`), otherwise Wipe-Lab won't work and you'll have to manually cleanup previously created VMs.
34+
35+
## How can I manually clean up a lab
36+
37+
Normally, when you run `Wipe-Lab` that should handle everything for you. But if there is a problem you can take these manual steps.
38+
39+
+ Open the Hyper-V manager and manually shutdown or turn off the virtual machines in your lab configuration.
40+
+ In the Hyper-V manager, manually select each virtual machine and delete it.
41+
+ Open Windows Explorer or a PowerShell prompt and change to the configuration directory.
42+
+ Manually delete any MOF files.
43+
+ Change to C:\Autolab\VMVirtualDisks (or the drive where you have Autolab configured).
44+
+ Manually delete any files that are named with virtual machines from your configuration.
45+
46+
## How can I change a VM's timezone
47+
48+
1. First, find your desired timezone using one of these PowerShell commands:
49+
50+
```powershell
51+
# Filter all timezones, take the Id property from the desired timezone:
52+
[System.TimeZoneInfo]::GetSystemTimeZones().Where({$_.Id -like '*Eastern*'})
53+
54+
# Get your current timezone:
55+
(Get-TimeZone).Id
56+
```
57+
58+
2. Open the lab's `Lab-Name.psd1` and change `Lability_timeZone` per Node.
59+
60+
Another option is to use the `-UseLocalTimeZone` parameter when running `Setup-Lab` or `Unattend-Lab`. This will configure all virtual machines in the lab configuration to use the same time zone as the local host.
61+
62+
### last updated 2020-04-23 18:21:49Z UTC

Configurations/PowerShellLab/VMValidate.test.ps1

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Describe DOM1 {
7474
}
7575
}
7676
} #if ous
77-
77+
7878
$groups = Invoke-Command {
7979
Try {
8080
Get-ADGroup -filter * -ErrorAction Stop
@@ -156,7 +156,7 @@ Describe DOM1 {
156156
}
157157
}
158158
Catch {
159-
It "[DOM1] Should allow a PSSession" {
159+
It "[DOM1] Should allow a PSSession but got error: $($_.exception.message)" {
160160
$false | Should Be $True
161161
}
162162
}
@@ -193,7 +193,7 @@ Describe SRV1 {
193193
}
194194
}
195195
Catch {
196-
It "[SRV1] Should allow a PSSession" {
196+
It "[SRV1] Should allow a PSSession but got error: $($_.exception.message)" {
197197
$false | Should Be $True
198198
}
199199
}
@@ -244,7 +244,7 @@ Describe SRV2 {
244244
}
245245
}
246246
Catch {
247-
It "[SRV2] Should allow a PSSession" {
247+
It "[SRV2] Should allow a PSSession but got error: $($_.exception.message)" {
248248
$false | Should Be $True
249249
}
250250
}
@@ -280,7 +280,7 @@ Describe SRV3 {
280280
}
281281
}
282282
Catch {
283-
It "[SRV3] Should allow a PSSession" {
283+
It "[SRV3] Should allow a PSSession but got error: $($_.exception.message)" {
284284
$false | Should Be $True
285285
} }
286286
}
@@ -297,9 +297,8 @@ Describe Win10 {
297297
$test.domain | Should Be $Domain
298298
}
299299

300-
It "[WIN10] Should be running Windows 10 Enterprise version 18362" {
300+
It "[WIN10] Should be running Windows 10 Enterprise" {
301301
$test = Invoke-Command { Get-CimInstance -ClassName win32_operatingsystem -property version, caption } -session $cl
302-
$test.Version | Should Be '10.0.18362'
303302
$test.caption | Should BeLike "*Enterprise*"
304303
}
305304

@@ -325,7 +324,7 @@ Describe Win10 {
325324
}
326325
}
327326
Catch {
328-
It "[Win10] Should allow a PSSession" {
327+
It "[Win10] Should allow a PSSession but got error: $($_.exception.message)" {
329328
$false | Should Be $True
330329
}
331330
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Lab Definition
2+
3+
This lab builds the following:
4+
5+
Computername : S12R2GUI
6+
Description : Windows Server 2012 R2 Standard 64bit English Evaluation with WMF 5.1
7+
Role :
8+
IPAddress : 192.168.3.122
9+
MemoryGB : 4
10+
11+
Administrator password is P@ssw0rd.
12+
13+
## To get started
14+
15+
To run the full lab setup, which includes Setup-Lab, Run-Lab, Enable-Internet, and Validate-Lab. You should run all commands from the directory with the MOF and psd1 files.
16+
17+
```powershell
18+
PS> Unattend-Lab
19+
```
20+
21+
To run the commands individually to setup the lab environment:
22+
23+
Run the following for initial setup:
24+
25+
```powershell
26+
PS> Setup-Lab
27+
```
28+
29+
To start the Lab, and apply configurations the first time:
30+
31+
```powershell
32+
PS> Run-Lab
33+
```
34+
35+
To enable Internet access for the VMs, run:
36+
37+
```powershell
38+
PS> Enable-Internet
39+
```
40+
41+
To validate when configurations have converged:
42+
43+
```powershell
44+
PS> Validate-Lab
45+
```
46+
47+
Or you can run the Pester test directly
48+
49+
```powershell
50+
PS> Invoke-Pester vmvalidate.test.ps1
51+
```
52+
53+
## To Stop and snapshot the lab
54+
55+
To stop the lab VMs:
56+
57+
```powershell
58+
PS> Shutdown-lab
59+
```
60+
61+
To checkpoint the VMs:
62+
63+
```powershell
64+
PS> Snapshot-Lab
65+
```
66+
67+
To quickly rebuild the labs from the checkpoint, run:
68+
69+
```powershell
70+
PS> Refresh-Lab
71+
```
72+
73+
## To Patch a lab
74+
75+
If you want to make sure the virtual machines have the latest updates from Microsoft, you can run this command:
76+
77+
```powershell
78+
PS> Update-Lab
79+
```
80+
81+
Because this may take some time to run, you can also run it as a background job.
82+
83+
```powershell
84+
PS> Update-Lab -asjob
85+
```
86+
87+
## To remove a lab
88+
89+
To destroy the lab to build again run:
90+
91+
```powershell
92+
PS> Wipe-Lab
93+
```
94+
95+
You will be prompted for each virtual machine. Or you can force the removal and suppress the prompts:
96+
97+
```powershell
98+
PS> Wipe-Lab -force
99+
```
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
2+
Configuration AutoLab {
3+
4+
$LabData = Import-PowerShellDataFile -Path $PSScriptRoot\*.psd1
5+
$Secure = ConvertTo-SecureString -String "$($labdata.allnodes.labpassword)" -AsPlainText -Force
6+
$credential = New-Object -typename Pscredential -ArgumentList Administrator, $secure
7+
8+
#region DSC Resources
9+
Import-DSCresource -ModuleName "PSDesiredStateConfiguration" -ModuleVersion "1.1"
10+
Import-DSCResource -modulename "xPSDesiredStateConfiguration" -ModuleVersion "9.1.0"
11+
Import-DSCResource -modulename "xComputerManagement" -ModuleVersion "4.1.0.0"
12+
Import-DSCResource -modulename "xNetworking" -ModuleVersion "5.7.0.0"
13+
14+
#endregion
15+
#region All Nodes
16+
node $AllNodes.Where( {$true}).NodeName {
17+
#endregion
18+
#region LCM configuration
19+
20+
LocalConfigurationManager {
21+
RebootNodeIfNeeded = $true
22+
AllowModuleOverwrite = $true
23+
ConfigurationMode = 'ApplyOnly'
24+
}
25+
26+
#endregion
27+
28+
#region Remove PowerShell v2
29+
30+
WindowsFeature PS2 {
31+
Name = 'PowerShell-V2'
32+
Ensure = 'Absent'
33+
}
34+
35+
#region
36+
37+
#region IPaddress settings
38+
39+
If (-not [System.String]::IsNullOrEmpty($node.IPAddress)) {
40+
xIPAddress 'PrimaryIPAddress' {
41+
IPAddress = $node.IPAddress
42+
InterfaceAlias = $node.InterfaceAlias
43+
AddressFamily = $node.AddressFamily
44+
}
45+
46+
If (-not [System.String]::IsNullOrEmpty($node.DefaultGateway)) {
47+
xDefaultGatewayAddress 'PrimaryDefaultGateway' {
48+
InterfaceAlias = $node.InterfaceAlias
49+
Address = $node.DefaultGateway
50+
AddressFamily = $node.AddressFamily
51+
}
52+
}
53+
54+
If (-not [System.String]::IsNullOrEmpty($node.DnsServerAddress)) {
55+
xDnsServerAddress 'PrimaryDNSClient' {
56+
Address = $node.DnsServerAddress
57+
InterfaceAlias = $node.InterfaceAlias
58+
AddressFamily = $node.AddressFamily
59+
}
60+
}
61+
62+
If (-not [System.String]::IsNullOrEmpty($node.DnsConnectionSuffix)) {
63+
xDnsConnectionSuffix 'PrimaryConnectionSuffix' {
64+
InterfaceAlias = $node.InterfaceAlias
65+
ConnectionSpecificSuffix = $node.DnsConnectionSuffix
66+
}
67+
}
68+
} #End IF
69+
70+
#endregion
71+
72+
#region Firewall Rules
73+
74+
$LabData = Import-PowerShellDataFile -Path $psscriptroot\*.psd1
75+
$FireWallRules = $labdata.Allnodes.FirewallRuleNames
76+
77+
foreach ($Rule in $FireWallRules) {
78+
xFirewall $Rule {
79+
Name = $Rule
80+
Enabled = 'True'
81+
}
82+
} #End foreach
83+
84+
} #end Firewall Rules
85+
#endregion
86+
87+
} # End AllNodes
88+
#endregion
89+
90+
AutoLab -OutputPath $PSScriptRoot -ConfigurationData $PSScriptRoot\*.psd1
91+

0 commit comments

Comments
 (0)