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

Commit 5f5aa1c

Browse files
v4.19.0
1 parent 46804d3 commit 5f5aa1c

34 files changed

+1018
-197
lines changed

Detailed-Setup-Instructions.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Please refer to this document to assist in installing and setting up the `PSAutolab` module on your computer. Run all commands from an **elevated** Windows PowerShell session. In other words, *run Windows PowerShell as administrator*. You will know you are elevated if you see the word `Administrator` in the title bar of the PowerShell window. __Do NOT run this module in PowerShell 7__. It is assumed you are running this on Windows 10 Professional or Enterprise editions.
44

5-
It is also assumed that you have administrator rights to your computer and can makes changes. If your computer is controlled by Group Policy, you may encounter problems. You should also be logged in with a local or domain user account. The setup process may not work properly if using an O365 or Microsoft account to logon to Windows.
5+
It is also assumed that you have administrator rights to your computer and can make changes. If your computer is controlled by Group Policy, you may encounter problems. You should also be logged in with a local or domain user account. The setup process may not work properly if using an O365 or Microsoft account to logon to Windows.
66

77
It is *possible* to run this module with nested virtualization inside a Windows 10 Hyper-V virtual machine but it is **not** recommended. Some networking features may not work properly and overall performance will likely be reduced.
88

@@ -20,7 +20,7 @@ Caption MemoryGB
2020
Microsoft Windows 10 Pro 32
2121
```
2222

23-
If the Caption shows anything other than Pro or Enterprise this module may not work. Although it appears that Windows 10 Education might be supported. In fact, if you can't even open a PowerShell prompt, this module won't work on your computer.
23+
If the Caption shows anything other than Pro or Enterprise this module may not work. Although it appears that Windows 10 Education might be supported. If you can't even open a PowerShell prompt, this module won't work on your computer.
2424

2525
The memory size should be at least 12GB. 16GB or greater is recommended. If the number is less than 12, **STOP**. It is unlikely you have enough installed memory. Depending on the configuration you want to run, it *might* be possible to proceed with less memory. Open an Issue and ask for guidance indicating your memory settings from this command:
2626

@@ -74,6 +74,22 @@ You should have close to 100GB of free space on a fixed hard drive such as C or
7474

7575
The module requires the Hyper-V feature on Windows 10. Please refer to the documentation for your computer hardware to determine if it supports virtualization. You may need to configure settings in your BIOS. You don't need to manually enable the Hyper-V feature now, although you are welcome to if you want to verify it is available.
7676

77+
### Pester
78+
79+
The module uses a standard PowerShell tool called Pester to validate lab configurations. Without getting into technical details, if you are running the out-of-the-box version of Pester on Windows 10, **you need to manually update Pester** before attempting to install this module. In an elevated Windows PowerShell session run this command:
80+
81+
```powershell
82+
Get-Module Pester -ListAvailable
83+
```
84+
85+
If the _only_ result you get is for version `3.4.0`, then you must run:
86+
87+
```powershell
88+
Install-Module pester -RequiredVersion 4.10.1 -Force -SkipPublisherCheck
89+
```
90+
91+
Re-run the `Get-Module` to verify version `4.10.1` is installed. If you have newer versions installed, that will have no effect on this module. Once you have verified Pester version 4.10.1 you can install the PSAutolab module.
92+
7793
## Installation and Configuration
7894

7995
### Install the Module
@@ -94,7 +110,7 @@ PS C:\> Get-Module PSAutoLab -list
94110
95111
ModuleType Version Name ExportedCommands
96112
---------- ------- ---- ----------------
97-
Script 4.16.0 PSAutoLab {Enable-Internet, Invoke-RefreshLab, Invoke-Run...
113+
Script 4.19.0 PSAutoLab {Enable-Internet, Invoke-RefreshLab, Invoke-Run...
98114
```
99115

100116
You may see a newer version number than what is indicated here. The `README` file indicates the current version in the PowerShell Gallery.
@@ -130,8 +146,9 @@ PctFreeMemory : 59.71
130146
Processor : Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
131147
IsElevated : True
132148
RemotingEnabled : True
149+
NetConnectionProfile : Private
133150
HyperV : 10.0.18362.1
134-
PSAutolab : 4.16.0
151+
PSAutolab : 4.19.0
135152
Lability : {0.19.1, 0.19.0, 0.18.0}
136153
Pester : {5.0.2, 4.10.1, 4.9.0, 4.8.1...}
137154
PowerShellGet : 2.2.4.1
@@ -159,20 +176,7 @@ Or open the file with Notepad.
159176

160177
Another option is to use the `Get-LabSummary` command. This will show you what computers will be created and how they will be created. The Computername will also be the virtual machine name.
161178

162-
```text
163-
PS C:\Autolab\Configurations\SingleServer-GUI-2016\> Get-LabSummary
164-
165-
166-
Computername : S1
167-
VMName : S1
168-
InstallMedia : 2016_x64_Standard_EN_Eval
169-
Description : Windows Server 2016 Standard 64bit English Evaluation
170-
Role : RDP
171-
IPAddress : 192.168.3.75
172-
MemoryGB : 4
173-
Processors : 1
174-
Lab : SingleServer-GUI-2016
175-
```
179+
![Get-LabSummary](images/get-labsummary.png)
176180

177181
You can run `Unattend-Lab` for a completely hands-free experience.
178182

@@ -198,7 +202,7 @@ If you encounter errors running an unattended setup, you should step through the
198202

199203
Errors that affect setup should happen in one of these steps. If so, open an issue with the configuration name, the command you were working on and the error message. Also include the output from `Get-PSAutolabSetting`.
200204

201-
After about 10 minutes, you can manually test to see if the configuration has finalized.
205+
After about 10 minutes, you can manually test to see if the configuration has converged.
202206

203207
```powershell
204208
Invoke-Pester .\vmvalidate.test.ps1
@@ -232,13 +236,13 @@ NonNodeData = @{
232236
#EnvironmentPrefix = 'AutoLab-'
233237
```
234238

235-
Remove the `#` character before `EnvironmentPrefix`. If you want to change the value from `Autolab-` to something else go ahead. The prefix will be inserted before the computername to create the virtual machine name.
239+
Remove the `#` character before `EnvironmentPrefix`. If you want to change the value from `Autolab-` to something else go ahead. The prefix will be inserted before the computer name to create the virtual machine name.
236240

237241
This setting should only be used in special situations as it can be confusing. While every effort has been made to ensure compatibility with commands in this module, there is no guarantee of 100% success. Also note that any changes you make to the configuration files could be overwritten in future updates or when you run `Refresh-Host`.
238242

239243
## Troubleshooting Tips
240244

241-
Occasionally, things can go wrong for no apparent reason. If you ran through the manual steps to setup a lab but the validations tests is still failing, you may need to stop and restart the virtual machine that is causing problems. For example, *sometimes* the SRV2 member in the `PowerShellLab` configuration simply won't pass validation, often because it can't be connected to. The best solution is to shut down the virtual machine in either the Hyper-V Manager or from PowerShell.
245+
Occasionally, things can go wrong for no apparent reason. If you ran through the manual steps to setup a lab but the validation tests are still failing, you may need to stop and restart the virtual machine that is causing problems. For example, *sometimes* the SRV2 member in the `PowerShellLab` configuration simply won't pass validation, often because it can't be connected to. The best solution is to shut down the virtual machine in either the Hyper-V Manager or from PowerShell.
242246

243247
```powershell
244248
Stop-VM srv2 -force
@@ -256,4 +260,4 @@ Wait about 5 minutes and then test again.
256260

257261
If encounter problems getting any of this to work, you are welcome to post an Issue. If you get the module installed, please include the results of `Get-PSAutolabSetting`. If your problem is meeting one of the requirements, we will do our best to help. Although if your computer is locked down or otherwise controlled by corporate policies there may not be much that we can do.
258262

259-
last updated 2020-10-06 15:37:01Z
263+
Last Updated 2020-12-01 22:15:58Z

ModuleCommands.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Module Commands
2+
3+
Most of the commands in the module use a domain-specific language (DSL), or a set of aliases to reference the actual commands. This DSL is intended to make it easier for beginner PowerShell users to use this module. Experienced users are welcome to use the proper command names if they wish.

PSAutoLab.psd1

178 Bytes
Binary file not shown.

PSAutoLabManual.pdf

1.88 MB
Binary file not shown.

PrepAdoc.ps1

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
[cmdletbinding(SupportsShouldProcess)]
2+
Param(
3+
[Parameter(Position = 0)]
4+
[ValidateNotNullOrEmpty()]
5+
[ValidateScript( {Test-Path $_})]
6+
[string]$Path = ".",
7+
[Parameter(HelpMessage = "The path to a json file with the processing data for the folder.")]
8+
[ValidateNotNullOrEmpty()]
9+
[ValidateScript( {Test-Path $_})]
10+
[string]$DataPath = ".\adoc-data.json"
11+
)
12+
13+
$prog = @{
14+
Activity = "Prepare ADOC files"
15+
Status = "Initializing"
16+
CurrentOperation = ""
17+
PercentComplete = 0
18+
}
19+
20+
Write-Progress @prog
21+
22+
$ModulePath = Convert-Path $Path
23+
$moduleName = Split-Path $modulePath -leaf
24+
Write-Verbose "[$(Get-Date)] Working from $modulePath"
25+
26+
Write-Verbose "[$(Get-Date)] Importing ruby-related functions"
27+
. C:\scripts\rubydocs.ps1
28+
29+
Write-Verbose "[$(Get-Date)] Importing adoc data from json"
30+
<#
31+
{
32+
"Name" : "PSScriptToolsManual",
33+
"Title": "PSScriptTools Manual",
34+
"CodeTheme": "githubcustom",
35+
"CodeThemePath": "c:\\scripts\\githubcustom.rb",
36+
"Theme": "pdf-theme.yml",
37+
"Files": [
38+
{
39+
"Name": "Intro.md",
40+
"Lines": ""
41+
},
42+
{
43+
"Name": "README.md",
44+
"Lines": "1;13..15;33..-1"
45+
},
46+
{
47+
"Name": "ModuleCommands.md",
48+
"Lines": ""
49+
}
50+
]
51+
}#>
52+
53+
$data = Get-Content $DataPath | ConvertFrom-Json
54+
55+
Write-Verbose "[$(Get-Date)] Get the module version"
56+
$ver = (Test-ModuleManifest -Path .\$modulename.psd1).version.tostring()
57+
#(Import-PowerShellDataFile $ModulePath\*.psd1).moduleversion
58+
Write-Verbose "[$(Get-Date)] Found version $ver"
59+
60+
#update pdf-them.yml with the module version
61+
Write-Verbose "[$(Get-Date)] Updating book theme yml file"
62+
New-BookThemeYml -version $ver -title "PSAutoLab Help Manual" -image images/command-console_orange.png
63+
64+
#define a here-string for the main document in Asciidoctor format
65+
$Main = @"
66+
= $($data.title) v$Ver
67+
:allow-uri-read:
68+
:autofit-option:
69+
:data-uri:
70+
:icons: font
71+
:iconset: fa
72+
:linkattrs:
73+
:rouge-style: $($data.codeTheme)
74+
:source-highlighter: rouge
75+
:toc:
76+
:toclevels: 1
77+
78+
"@
79+
80+
$files = $data.files
81+
$prog.status = "Processing main files"
82+
$i = 0
83+
foreach ($file in $files) {
84+
$i++
85+
$prog.CurrentOperation = $file.name
86+
$prog.percentComplete = ($i/$files.count)*100
87+
Write-Progress @prog
88+
$item = Join-Path -Path $Modulepath -ChildPath $file.name
89+
Write-Verbose "[$(Get-Date)] Converting $item"
90+
Get-Item -path $item |
91+
ConvertTo-Adoc -Codetheme $data.codeTheme
92+
93+
$adoc = $item -replace "md", "adoc"
94+
$c = Get-Content $adoc
95+
96+
Write-Verbose "[$(Get-Date)] Adjustings links and xrefs"
97+
[regex]$lx = "xref:(?<link>\S+)\.adoc\[(?<display>((\w+[\s-]\w+))+)\]"
98+
$matchData = $lx.matches($c)
99+
foreach ($item in $matchData) {
100+
$link = $item.groups.where( {$_.name -eq 'link'}).value
101+
$display = $item.groups.where( {$_.name -eq 'display'}).value
102+
103+
#split off the command name from the link to build the
104+
#correct cross-reference in the PDF
105+
$cmdName = $link.split("/")[-1]
106+
$xlink = "$cmdName-Help"
107+
$xref = "<<{0},{1}>>" -f $xlink, $display
108+
#use the method because the value has regex characters
109+
$c = $c.replace($item.value, $xref)
110+
}
111+
112+
[regex]$lastrx = "[Ll]ast [uU]pdated\s.*"
113+
$lastMatch = $lastrx.match($c)
114+
if ($lastMatch.value) {
115+
Write-Verbose "[$(Get-Date)] Strip off Last Update line"
116+
$c = $c.replace($lastMatch.value," ")
117+
}
118+
119+
Write-Verbose "[$(Get-Date)] Updating $adoc"
120+
$c | Out-File -FilePath $adoc -Encoding utf8
121+
122+
Write-Verbose "[$(Get-Date)] Adding to Main"
123+
#include line subsets if defined
124+
if ($file.lines) {
125+
$trim = "lines=$($file.lines)"
126+
}
127+
else {
128+
$trim = ""
129+
}
130+
$main += @"
131+
132+
include::$($adoc)[$trim]
133+
134+
"@
135+
}
136+
137+
Write-Verbose "[$(Get-Date)] Creating adoc help files. You may need to press Enter to force the process to continue."
138+
139+
#create the adoc files and then edit them.
140+
$prog.Status = "Converting markdown to adoc files"
141+
$prog.CurrentOperation =
142+
$i = 0
143+
$helpMD = Get-ChildItem $ModulePath\docs\*-*.md
144+
145+
$helpmd | ForEach-Object {
146+
$i++
147+
$prog.CurrentOperation = $_.FullName
148+
$prog.percentComplete = ($i/$helpmd.count)*100
149+
Write-Progress @prog
150+
ConvertTo-Adoc -Fullname $_.fullname -passthru -theme $data.codeTheme | Edit-Adoc
151+
}
152+
153+
$prog.status = "Building main document"
154+
Write-Verbose "[$(Get-Date)] Add include links to the main document"
155+
$adocs = Get-ChildItem $ModulePath\docs\*.adoc -OutVariable ov | Sort-Object -property Name
156+
157+
$i = 0
158+
ForEach ($item in $adocs) {
159+
$i++
160+
$prog.CurrentOperation = $item.name
161+
$prog.percentComplete = ($i/$adocs.count)*100
162+
Write-Progress @prog
163+
Write-Verbose "[$(Get-Date)] Adding $($item.name)"
164+
$main += @"
165+
166+
include::docs\$($item.name)[]
167+
168+
"@
169+
}
170+
171+
<#Add Changelog
172+
Write-Verbose "[$(Get-Date)] Adding ChangeLog"
173+
ConvertTo-Adoc -Fullname $PSScriptRoot\ChangeLog.md -passthru -theme $data.codeTheme
174+
$log = Join-Path -Path $Modulepath -ChildPath Changelog.adoc
175+
176+
#convert headings to bold monospace
177+
$content = Get-Content -path $log
178+
179+
[regex]$rxVer = "==\s(?<version>v\d+\.\d+\.\d+)"
180+
181+
$rxver.matches($content) | foreach-Object {
182+
$Find = $_.value
183+
$Replace = "``*$($_.groups[1].value)``*"
184+
Write-Verbose "[$(Get-Date)] Replace '$find' with $Replace"
185+
$content = $content.replace($Find,$Replace)
186+
}
187+
188+
$content | Out-File $log -Encoding utf8
189+
$main += @"
190+
191+
include::$log[]
192+
193+
"@
194+
195+
#>
196+
$out = Join-Path -path $ModulePath -child "$($data.name).adoc"
197+
198+
$prog.status = "Finalizing"
199+
$prog.CurrentOperation = $out
200+
Write-Progress @prog
201+
Write-Verbose "[$(Get-Date)] Saving document to $out"
202+
$main | Out-File -FilePath $out -Encoding utf8
203+
204+
Write-Progress -Activity $prog.Activity -Completed
205+
206+
$msg = "Edit and review the adoc files and then run makepdf.ps1."
207+
Write-Host $msg -ForegroundColor Cyan
208+
209+
Write-Verbose "[$(Get-Date)] Finished."

0 commit comments

Comments
 (0)