-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathInstall-AutomatedBadLab.ps1
More file actions
54 lines (49 loc) · 1.99 KB
/
Copy pathInstall-AutomatedBadLab.ps1
File metadata and controls
54 lines (49 loc) · 1.99 KB
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
49
50
51
52
53
54
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 -match '^\s*[Yy]') {
$DownloadAllISOs = Read-Host "[!] Do you want to download ALL Evaluation ISOs without prompts? (Y/N)"
if ($DownloadAllISOs -match '^\s*[Yy]') {
& "$PSScriptRoot\Get-EvaluationISOs.ps1" -All
}
else {
& "$PSScriptRoot\Get-EvaluationISOs.ps1"
}
}
If ($RestartRequired) {
$Restart = Read-Host "[!] AutomatedLab setup complete! Do you want to restart the machine now? (Y/N)"
if ($Restart -match '^\s*[Yy]') {
Restart-Computer -Force
}
}
Else {
Write-Host "[+] AutomatedLab setup complete!"
}