This repository has been archived by the owner on Nov 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee78d4d
commit 0994fbf
Showing
18 changed files
with
1,050 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
Oops, something went wrong.