2024-11-24 20:14:10 +00:00
|
|
|
function InstallWinget
|
|
|
|
{
|
2024-11-25 10:23:03 +00:00
|
|
|
$download = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
|
|
|
|
$setup = "$env:TMP\winget_setup.msixbundle"
|
|
|
|
|
|
|
|
if (-not (Test-Path $setup))
|
|
|
|
{
|
|
|
|
$releases = Invoke-RestMethod $download
|
|
|
|
$assets = $releases | Select-Object -ExpandProperty "assets"
|
|
|
|
$installer = $assets | Where-Object "name" -Match "msixbundle"
|
|
|
|
$url = $installer | Select-Object -ExpandProperty "browser_download_url"
|
|
|
|
Invoke-RestMethod $url -OutFile $setup
|
|
|
|
}
|
|
|
|
|
|
|
|
Add-AppxPackage -Path $setup
|
2024-11-24 20:14:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function WingetInstall
|
|
|
|
{
|
2024-11-24 21:59:51 +00:00
|
|
|
$update = Read-Host "Install/Update WinGet now? [Y/n]"
|
|
|
|
if ($update.ToLower() -ne 'n')
|
2024-11-24 20:29:15 +00:00
|
|
|
{
|
|
|
|
# Start admin process, import this script, run 'InstallPackages' function
|
2024-11-24 20:35:50 +00:00
|
|
|
Start-Process powershell.exe -Verb RunAs -Wait `
|
2024-11-24 20:51:25 +00:00
|
|
|
-ArgumentList "-ExecutionPolicy", "Bypass", `
|
2024-11-24 21:39:20 +00:00
|
|
|
"-C", "cd $pwd; ipmo ./util/winget.psm1; InstallWinget"
|
2024-11-24 20:14:10 +00:00
|
|
|
}
|
|
|
|
|
2024-11-24 21:59:51 +00:00
|
|
|
$install = Read-Host "Install WinGet Packages now? [Y/n]"
|
|
|
|
if ($install.ToLower() -eq 'n')
|
|
|
|
{ return
|
|
|
|
}
|
|
|
|
|
2024-11-24 20:14:10 +00:00
|
|
|
winget.exe install -s winget --accept-source-agreements (Get-Content ./util/winget.list)
|
|
|
|
}
|