-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart.ps1
30 lines (26 loc) · 1.11 KB
/
start.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
Write-Host "Installing Virtual Environment ""win20199"""
Write-Host "Validating packer script ""hv_win2019_g2.pkr.hcl"" . . ."
$validate = packer validate -var-file variables_win2019_std.pkvars.hcl win2019_g2.pkr.hcl
if ($validate[-1] -eq "The configuration is valid.")
{
Write-Host $validate[-1] -ForegroundColor Green
}
else
{
Write-Host $validate -ForegroundColor Red
}
Write-Host "Building virtual machine . . ."
Write-Host "This may take a long time"
packer build -force -var-file variables_win2019_std.pkvars.hcl win2019_g2.pkr.hcl
$vhd = Test-Path ".\output-windows-2019-g2\Virtual Hard Disks\packer-windows2019-g2.vhdx"
$readme = Test-Path .\output-windows-2019-g2\Windows2019-Readme.md
if ($vhd -and $readme)
{
Write-Host "Virtual machine created successfully" -ForegroundColor Green
Write-Host "Artifacts: "".\output-windows-2019-g2\Virtual Hard Disks\packer-windows2019-g2.vhdx""" -ForegroundColor Green
Write-Host "Artifacts: "".\output-windows-2019-g2\Windows2019-Readme.md""" -ForegroundColor Green
}
else
{
Write-Host "Failed to create virtual machine! See build logs above" -ForegroundColor Red
}