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

Commit

Permalink
v4.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Apr 23, 2020
1 parent ee78d4d commit 0994fbf
Show file tree
Hide file tree
Showing 18 changed files with 1,050 additions and 321 deletions.
62 changes: 62 additions & 0 deletions Authoring-FAQ.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Authoring FAQ

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.

**It is not recommended to attempt to author your own configuration without solid PowerShell, Desired State Configuration and Hyper-V experience.**

## How do I specify a different operating system

First, find the node information in the VMConfigurationData.psd1 file.

```powershell
@{
NodeName = 'S1'
IPAddress = '192.168.3.50'
#Role = 'DomainJoin' # example of multiple roles @('DomainJoin', 'Web')
Role = @('DomainJoin', 'Web')
Lability_BootOrder = 20
Lability_timeZone = 'US Mountain Standard Time' #[System.TimeZoneInfo]::GetSystemTimeZones()
Lability_Media = '2019_x64_Standard_EN_Core_Eval'
}
```

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.

## I'm getting an error when my VM is booting for the first time

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.*

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

## How can I avoid issues when changing VM names

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.

## How can I manually clean up a lab

Normally, when you run `Wipe-Lab` that should handle everything for you. But if there is a problem you can take these manual steps.

+ Open the Hyper-V manager and manually shutdown or turn off the virtual machines in your lab configuration.
+ In the Hyper-V manager, manually select each virtual machine and delete it.
+ Open Windows Explorer or a PowerShell prompt and change to the configuration directory.
+ Manually delete any MOF files.
+ Change to C:\Autolab\VMVirtualDisks (or the drive where you have Autolab configured).
+ Manually delete any files that are named with virtual machines from your configuration.

## How can I change a VM's timezone

1. First, find your desired timezone using one of these PowerShell commands:

```powershell
# Filter all timezones, take the Id property from the desired timezone:
[System.TimeZoneInfo]::GetSystemTimeZones().Where({$_.Id -like '*Eastern*'})
# Get your current timezone:
(Get-TimeZone).Id
```

2. Open the lab's `Lab-Name.psd1` and change `Lability_timeZone` per Node.

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.

### last updated 2020-04-23 18:21:49Z UTC
15 changes: 7 additions & 8 deletions Configurations/PowerShellLab/VMValidate.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Describe DOM1 {
}
}
} #if ous

$groups = Invoke-Command {
Try {
Get-ADGroup -filter * -ErrorAction Stop
Expand Down Expand Up @@ -156,7 +156,7 @@ Describe DOM1 {
}
}
Catch {
It "[DOM1] Should allow a PSSession" {
It "[DOM1] Should allow a PSSession but got error: $($_.exception.message)" {
$false | Should Be $True
}
}
Expand Down Expand Up @@ -193,7 +193,7 @@ Describe SRV1 {
}
}
Catch {
It "[SRV1] Should allow a PSSession" {
It "[SRV1] Should allow a PSSession but got error: $($_.exception.message)" {
$false | Should Be $True
}
}
Expand Down Expand Up @@ -244,7 +244,7 @@ Describe SRV2 {
}
}
Catch {
It "[SRV2] Should allow a PSSession" {
It "[SRV2] Should allow a PSSession but got error: $($_.exception.message)" {
$false | Should Be $True
}
}
Expand Down Expand Up @@ -280,7 +280,7 @@ Describe SRV3 {
}
}
Catch {
It "[SRV3] Should allow a PSSession" {
It "[SRV3] Should allow a PSSession but got error: $($_.exception.message)" {
$false | Should Be $True
} }
}
Expand All @@ -297,9 +297,8 @@ Describe Win10 {
$test.domain | Should Be $Domain
}

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

Expand All @@ -325,7 +324,7 @@ Describe Win10 {
}
}
Catch {
It "[Win10] Should allow a PSSession" {
It "[Win10] Should allow a PSSession but got error: $($_.exception.message)" {
$false | Should Be $True
}
}
Expand Down
99 changes: 99 additions & 0 deletions Configurations/SingleServer2012R2-GUI/Instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Lab Definition

This lab builds the following:

Computername : S12R2GUI
Description : Windows Server 2012 R2 Standard 64bit English Evaluation with WMF 5.1
Role :
IPAddress : 192.168.3.122
MemoryGB : 4

Administrator password is P@ssw0rd.

## To get started

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.

```powershell
PS> Unattend-Lab
```

To run the commands individually to setup the lab environment:

Run the following for initial setup:

```powershell
PS> Setup-Lab
```

To start the Lab, and apply configurations the first time:

```powershell
PS> Run-Lab
```

To enable Internet access for the VMs, run:

```powershell
PS> Enable-Internet
```

To validate when configurations have converged:

```powershell
PS> Validate-Lab
```

Or you can run the Pester test directly

```powershell
PS> Invoke-Pester vmvalidate.test.ps1
```

## To Stop and snapshot the lab

To stop the lab VMs:

```powershell
PS> Shutdown-lab
```

To checkpoint the VMs:

```powershell
PS> Snapshot-Lab
```

To quickly rebuild the labs from the checkpoint, run:

```powershell
PS> Refresh-Lab
```

## To Patch a lab

If you want to make sure the virtual machines have the latest updates from Microsoft, you can run this command:

```powershell
PS> Update-Lab
```

Because this may take some time to run, you can also run it as a background job.

```powershell
PS> Update-Lab -asjob
```

## To remove a lab

To destroy the lab to build again run:

```powershell
PS> Wipe-Lab
```

You will be prompted for each virtual machine. Or you can force the removal and suppress the prompts:

```powershell
PS> Wipe-Lab -force
```
91 changes: 91 additions & 0 deletions Configurations/SingleServer2012R2-GUI/VMConfiguration.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

Configuration AutoLab {

$LabData = Import-PowerShellDataFile -Path $PSScriptRoot\*.psd1
$Secure = ConvertTo-SecureString -String "$($labdata.allnodes.labpassword)" -AsPlainText -Force
$credential = New-Object -typename Pscredential -ArgumentList Administrator, $secure

#region DSC Resources
Import-DSCresource -ModuleName "PSDesiredStateConfiguration" -ModuleVersion "1.1"
Import-DSCResource -modulename "xPSDesiredStateConfiguration" -ModuleVersion "9.1.0"
Import-DSCResource -modulename "xComputerManagement" -ModuleVersion "4.1.0.0"
Import-DSCResource -modulename "xNetworking" -ModuleVersion "5.7.0.0"

#endregion
#region All Nodes
node $AllNodes.Where( {$true}).NodeName {
#endregion
#region LCM configuration

LocalConfigurationManager {
RebootNodeIfNeeded = $true
AllowModuleOverwrite = $true
ConfigurationMode = 'ApplyOnly'
}

#endregion

#region Remove PowerShell v2

WindowsFeature PS2 {
Name = 'PowerShell-V2'
Ensure = 'Absent'
}

#region

#region IPaddress settings

If (-not [System.String]::IsNullOrEmpty($node.IPAddress)) {
xIPAddress 'PrimaryIPAddress' {
IPAddress = $node.IPAddress
InterfaceAlias = $node.InterfaceAlias
AddressFamily = $node.AddressFamily
}

If (-not [System.String]::IsNullOrEmpty($node.DefaultGateway)) {
xDefaultGatewayAddress 'PrimaryDefaultGateway' {
InterfaceAlias = $node.InterfaceAlias
Address = $node.DefaultGateway
AddressFamily = $node.AddressFamily
}
}

If (-not [System.String]::IsNullOrEmpty($node.DnsServerAddress)) {
xDnsServerAddress 'PrimaryDNSClient' {
Address = $node.DnsServerAddress
InterfaceAlias = $node.InterfaceAlias
AddressFamily = $node.AddressFamily
}
}

If (-not [System.String]::IsNullOrEmpty($node.DnsConnectionSuffix)) {
xDnsConnectionSuffix 'PrimaryConnectionSuffix' {
InterfaceAlias = $node.InterfaceAlias
ConnectionSpecificSuffix = $node.DnsConnectionSuffix
}
}
} #End IF

#endregion

#region Firewall Rules

$LabData = Import-PowerShellDataFile -Path $psscriptroot\*.psd1
$FireWallRules = $labdata.Allnodes.FirewallRuleNames

foreach ($Rule in $FireWallRules) {
xFirewall $Rule {
Name = $Rule
Enabled = 'True'
}
} #End foreach

} #end Firewall Rules
#endregion

} # End AllNodes
#endregion

AutoLab -OutputPath $PSScriptRoot -ConfigurationData $PSScriptRoot\*.psd1

Loading

0 comments on commit 0994fbf

Please sign in to comment.