-
Notifications
You must be signed in to change notification settings - Fork 5
/
Install-AutomatedBadLab.ps1
48 lines (43 loc) · 1.74 KB
/
Install-AutomatedBadLab.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Write-Host "[+] Checking if HyperV is installed"
$os = Get-CimInstance -ClassName Win32_OperatingSystem
if ($os.ProductType -eq 1) {
if ((Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online).State -ne "Enabled") {
Write-Host " [!] HyperV not found. Installing.."
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All -All -NoRestart
Write-Host " [!] HyperV Installed! Please restart machine before building machines."
$RestartRequired = $true
}
else {
Write-Host " [+] HyperV is already installed!"
}
} else {
if (!(Get-WindowsFeature -Name Hyper-V) -or (Get-WindowsFeature -Name Hyper-V).Installed -eq $false) {
Write-Host " [!] HyperV not found. Installing.."
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools
Write-Host " [!] HyperV Installed! Please restart machine before building machines."
$RestartRequired = $true
}
else {
Write-Host " [+] HyperV is already installed!"
}
}
Write-Host "[+] Installing AutomatedLab module"
Install-PackageProvider Nuget -Force
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
Install-Module AutomatedLab -SkipPublisherCheck -AllowClobber
Write-Host "[+] Configuring AutomatedLab"
Enable-LabHostRemoting -Force
New-LabSourcesFolder -DriveLetter C
$DownloadISOs = Read-Host "[!] Do you want to download Evaluation ISOs? (Y/N)"
if ($DownloadISOs -eq "Y") {
& "$PSScriptRoot\Get-EvaluationISOs.ps1"
}
If ($RestartRequired) {
$Restart = Read-Host "[!] AutomatedLab setup complete! Do you want to restart the machine now? (Y/N)"
if ($Restart -eq "Y") {
Restart-Computer -Force
}
}
Else {
Write-Host "[+] AutomatedLab setup complete!"
}