diff --git a/packer/windowsserver2019.pkr.hcl b/packer/windowsserver2019.pkr.hcl index bda741a..89cacc4 100644 --- a/packer/windowsserver2019.pkr.hcl +++ b/packer/windowsserver2019.pkr.hcl @@ -195,22 +195,34 @@ build { } provisioner "powershell" { - inline = [ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12", - "Invoke-Expression ((New-Object Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" + scripts = [ + "scripts/Install-WinGet.ps1" ] } - provisioner "powershell" { - inline = [ - "choco config set --name=limit-output --value=LimitOutput", - "choco install -y dotnetfx", - "choco install -y 7zip.install", - "choco install -y sysinternals", - "choco install -y firefox" + inline = [ + "winget install mozilla.firefox", + "winget install 7zip.7zip", + "winget install microsoft.dotnetframework" ] - valid_exit_codes = [0, 3010] + // valid_exit_codes = [0, 3010] } + // provisioner "powershell" { + // inline = [ + // "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12", + // "Invoke-Expression ((New-Object Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" + // ] + // } + // provisioner "powershell" { + // inline = [ + // "choco config set --name=limit-output --value=LimitOutput", + // "choco install -y dotnetfx", + // "choco install -y 7zip.install", + // "choco install -y sysinternals", + // "choco install -y firefox" + // ] + // valid_exit_codes = [0, 3010] + // } provisioner "windows-update" { } @@ -287,9 +299,9 @@ build { inline = [ "qemu-img convert -f vmdk -O raw \\", " /scratch/srv2019-baremetal/${var.vm_guestos}-${var.vm_name}-baremetal-disk-0.vmdk \\", - " /tmp/srv2019-baremetal/${var.vm_guestos}-${var.vm_name}.raw", + " /tmp/${var.vm_guestos}-${var.vm_name}.raw", "gzip -c \\", - " /tmp/srv2019-baremetal/${var.vm_guestos}-${var.vm_name}.raw \\", + " /tmp/${var.vm_guestos}-${var.vm_name}.raw \\", " > /output/Windows-Server-2019-LTSC.raw.gz" ] } diff --git a/scripts/Install-WinGet.ps1 b/scripts/Install-WinGet.ps1 new file mode 100644 index 0000000..e52ec2e --- /dev/null +++ b/scripts/Install-WinGet.ps1 @@ -0,0 +1,18 @@ +[CmdletBinding()] +Param( + # None +) + +$InvokeRestMethodSplat = @{ + Uri = "https://api.github.com/repos/microsoft/winget-cli/releases/latest" + Method = 'GET' +} +$InvokeWebRequestSplat = @{ + Uri = ((Invoke-RestMethod @InvokeRestMethodSplat).assets | Where-Object ${_.name -like '*.appxbundle'}).browser_download_url + Out = "$env:temp\winget.appxbundle" +} +Invoke-WebRequest @InvokeWebRequestSplat + +If (Test-Path -Path "$env:temp\winget.appxbundle") { + & dism.exe /Online /Add-ProvisionedAppxPackage /PackagePath:"$env:temp\winget.appxbundle" /SkipLicense +} \ No newline at end of file