Last active
February 17, 2020 13:16
-
-
Save codaamok/0b264da6088a662b172751d17f2a07d1 to your computer and use it in GitHub Desktop.
Install AutomatedLab and start CM-1902 lab build
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
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