This commit is contained in:
		| @@ -187,42 +187,42 @@ source "vsphere-iso" "srv2019-baremetal" { | |||||||
| build { | build { | ||||||
|   sources = [ |   sources = [ | ||||||
|     "source.vsphere-iso.srv2019-template", |     "source.vsphere-iso.srv2019-template", | ||||||
|     "source.vsphere-iso.srv2019-virtual", |     "source.vsphere-iso.srv2019-virtual" | ||||||
|     "source.vsphere-iso.srv2019-baremetal" |  | ||||||
|   ] |   ] | ||||||
|  |   // "source.vsphere-iso.srv2019-baremetal" | ||||||
|  |  | ||||||
|   provisioner "windows-update" { |   provisioner "windows-update" { | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // provisioner "powershell" { |   provisioner "powershell" { | ||||||
|   //   scripts = [ |     scripts = [ | ||||||
|   //     "scripts/Install-WinGet.ps1" |       "scripts/Install-WinGet.ps1" | ||||||
|   //   ] |     ] | ||||||
|   // } |   } | ||||||
|   // provisioner "powershell" { |  | ||||||
|   //   inline = [ |  | ||||||
|   //     "winget install mozilla.firefox", |  | ||||||
|   //     "winget install 7zip.7zip", |  | ||||||
|   //     "winget install microsoft.dotnetframework" |  | ||||||
|   //   ] |  | ||||||
|   //   // valid_exit_codes = [0, 3010] |  | ||||||
|   // } |  | ||||||
|   provisioner "powershell" { |   provisioner "powershell" { | ||||||
|     inline = [ |     inline = [ | ||||||
|       "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12", |       "winget install mozilla.firefox", | ||||||
|       "Invoke-Expression ((New-Object Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" |       "winget install 7zip.7zip", | ||||||
|  |       "winget install microsoft.dotnetframework" | ||||||
|     ] |     ] | ||||||
|  |     // valid_exit_codes = [0, 3010] | ||||||
|   } |   } | ||||||
|   provisioner "powershell" { |   // provisioner "powershell" { | ||||||
|     inline           = [ |   //   inline = [ | ||||||
|       "choco config set --name=limit-output --value=LimitOutput", |   //     "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12", | ||||||
|       "choco install -y dotnetfx", |   //     "Invoke-Expression ((New-Object Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" | ||||||
|       "choco install -y 7zip.install", |   //   ] | ||||||
|       "choco install -y sysinternals", |   // } | ||||||
|       "choco install -y firefox" |   // provisioner "powershell" { | ||||||
|     ] |   //   inline           = [ | ||||||
|     valid_exit_codes = [0, 3010] |   //     "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" { |   provisioner "windows-update" { | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -3,22 +3,52 @@ Param( | |||||||
|     # None |     # None | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | # Download dependencies | ||||||
|  | $AppxDependencies = @( | ||||||
|  |     @{ | ||||||
|  |         ShortName     = 'vclibs' | ||||||
|  |         QualifiedName = 'Microsoft.VCLibs.140.00_8wekyb3d8bbwe' | ||||||
|  |     }, | ||||||
|  |     @{ | ||||||
|  |         ShortName     = 'vclibsuwp' | ||||||
|  |         QualifiedName = 'Microsoft.VCLibs.140.00.UWPDesktop_8wekyb3d8bbwe' | ||||||
|  |     } | ||||||
|  | ) | ||||||
|  | ForEach ($Dependency in $AppxDependencies) { | ||||||
|  |     $InvokeWebRequestSplat = @{ | ||||||
|  |         Uri             = 'https://store.rg-adguard.net/api/GetFiles' | ||||||
|  |         Method          = 'POST' | ||||||
|  |         ContentType     = 'application/x-www-form-urlencoded' | ||||||
|  |         Body            = "type=PackageFamilyName&url=$($Dependency.QualifiedName)&ring=RP&lang=en-US" | ||||||
|  |         UseBasicParsing = $True | ||||||
|  |     } | ||||||
|  |     $InvokeWebRequestSplat = @{ | ||||||
|  |         Uri     = ((Invoke-WebRequest @InvokeWebRequestSplat).Links | Where-Object {$_.OuterHTML -match '.appx' -and $_.outerHTML -match 'x64'}).href | ||||||
|  |         OutFile = "$env:temp/$($Dependency.ShortName).appx" | ||||||
|  |     } | ||||||
|  |     Invoke-WebRequest @InvokeWebRequestSplat | ||||||
|  | } | ||||||
|  | # Download latest release from github | ||||||
| $InvokeRestMethodSplat = @{ | $InvokeRestMethodSplat = @{ | ||||||
|     Uri    = "https://api.github.com/repos/microsoft/winget-cli/releases/latest" |     Uri    = "https://api.github.com/repos/microsoft/winget-cli/releases/latest" | ||||||
|     Method = 'GET' |     Method = 'GET' | ||||||
| } | } | ||||||
| $InvokeWebRequestSplat = @{ | $InvokeWebRequestSplat = @{ | ||||||
|     Uri = ((Invoke-RestMethod @InvokeRestMethodSplat).assets | Where-Object {$_.name -like '*.appxbundle'}).browser_download_url |     Uri     = ((Invoke-RestMethod @InvokeRestMethodSplat).assets | Where-Object {$_.name -like '*.appxbundle'}).browser_download_url | ||||||
|     Out = "$env:temp\winget.appxbundle" |     OutFile = "$env:temp\winget.appxbundle" | ||||||
| } | } | ||||||
| Invoke-WebRequest @InvokeWebRequestSplat | Invoke-WebRequest @InvokeWebRequestSplat | ||||||
|  |  | ||||||
| $InvokeWebRequestSplat = @{ | # Install dependencies | ||||||
|     Uri = "https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx" | $AppxDependencies.ShortName | ForEach-Object { | ||||||
|     Out = "$env:temp\vclibs.appx" |     $AddAppxPackageSplat = @{ | ||||||
|  |         Path = "$env:temp/$($_).appx" | ||||||
|  |     } | ||||||
|  |     Add-AppxPackage @AddAppxPackageSplat | ||||||
| } | } | ||||||
| Invoke-WebRequest @InvokeWebRequestSplat | # Install winget | ||||||
|  | $AddAppxPackageSplat = @{ | ||||||
|  |     Path = "$env:temp\winget.appxbundle" | ||||||
|  | } | ||||||
|  | Add-AppxPackage @AddAppxPackageSplat | ||||||
|  |  | ||||||
| If (Test-Path -Path "$env:temp\winget.appxbundle") { |  | ||||||
|     & dism.exe /Online /Add-ProvisionedAppxPackage /PackagePath:"$env:temp\winget.appxbundle" /SkipLicense /DependencyPackagePath:"$env:temp\vclibs.appx" |  | ||||||
| } |  | ||||||
		Reference in New Issue
	
	Block a user