Packer.Images/scripts/Install-WinGet.ps1

24 lines
791 B
PowerShell
Raw Normal View History

2021-06-22 07:54:45 +00:00
[CmdletBinding()]
Param(
# None
)
$InvokeRestMethodSplat = @{
Uri = "https://api.github.com/repos/microsoft/winget-cli/releases/latest"
Method = 'GET'
}
$InvokeWebRequestSplat = @{
2021-06-22 08:36:21 +00:00
Uri = ((Invoke-RestMethod @InvokeRestMethodSplat).assets | Where-Object {$_.name -like '*.appxbundle'}).browser_download_url
2021-06-22 07:54:45 +00:00
Out = "$env:temp\winget.appxbundle"
}
Invoke-WebRequest @InvokeWebRequestSplat
2021-06-22 11:44:06 +00:00
$InvokeWebRequestSplat = @{
Uri = "https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx"
Out = "$env:temp\vclibs.appx"
}
Invoke-WebRequest @InvokeWebRequestSplat
2021-06-22 07:54:45 +00:00
If (Test-Path -Path "$env:temp\winget.appxbundle") {
2021-06-22 11:44:06 +00:00
& dism.exe /Online /Add-ProvisionedAppxPackage /PackagePath:"$env:temp\winget.appxbundle" /SkipLicense /DependencyPackagePath:"$env:temp\vclibs.appx"
2021-06-22 07:54:45 +00:00
}