Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install AutomatedLab and start CM-1902 lab build
function Invoke-CM1902LabBuild {
if (-not(Get-Package -Name "AutomatedLab" -ProviderName "msi" -MinimumVersion "5.17.0")) {
$Path = "{0}\Downloads\AutomatedLab.msi" -f $HOME
Invoke-WebRequest -Uri "https://github.com/AutomatedLab/AutomatedLab/releases/latest/download/AutomatedLab.msi" -OutFile $Path -ErrorAction "Stop"
Start-Process "msiexec" -ArgumentList @("/i", $Path, "/qb") -Wait -ErrorAction "Stop"
}
try {
$Path = "{0}\Downloads\codaamok-PoSH" -f $HOME
git clone https://github.com/codaamok/PoSH.git $Path
}
catch [System.Management.Automation.CommandNotFoundException] {
throw "Git isn't installed, please install from https://git-scm.com/downloads"
}
catch {
throw
}
try {
$LabSourcesFolder = (Get-ItemProperty -Path "HKLM:\SOFTWARE\AutomatedLab Team\AutomatedLab" -Name "LabSourcesFolder" -ErrorAction "Stop").LabSourcesFolder
}
catch [System.Management.Automation.ItemNotFoundException] {
throw "Could not find AutomatedLab LabSources folder, is it installed?"
}
catch {
throw
}
Copy-Item -Path (Join-Path -Path $Path -ChildPath "AutomatedLab\CustomRoles\CM-1902\") -Destination (Join-Path -Path $LabSourcesFolder -ChildPath "CustomRoles\") -Recurse -Force -ErrorAction "Stop"
Write-Output ""
Write-Output "Complete the following before continuing:"
Write-Output "- Place an OS ISO in the following directory (Windows Server 2019/2016):"
Write-Output ("`t'{0}'" -f (Join-Path -Path $LabSourcesFolder -ChildPath "ISOs"))
Write-Output "- Create a Hyper-V external virtual switch named 'Internet', or cancel this and call CM-1902.ps1 with parameters '-ExternalVMSwitchName' or '-NoInternetAccess'"
Write-Output ""
$Y = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Continue with lab build"
$N = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Do not continue with lab build"
$Options = [System.Management.Automation.Host.ChoiceDescription[]]($Y, $N)
$Message = "Would you like to continue?"
$Result = $host.ui.PromptForChoice($null, $Message, $Options, 1)
if ($Result -ge 1) {
return
}
& "$($Path)\AutomatedLab\CM-1902.ps1"
}
Invoke-CM1902LabBuild
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.