dotfiles/util/winget.psm1

36 lines
1.1 KiB
PowerShell
Raw Normal View History

2024-11-24 20:14:10 +00:00
function InstallWinget
{
$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
{
$update = Read-Host "Install/Update WinGet now? [Y/n]"
if ($update.ToLower() -ne 'n')
{
# Start admin process, import this script, run 'InstallPackages' function
Start-Process powershell.exe -Verb RunAs -Wait `
-ArgumentList "-ExecutionPolicy", "Bypass", `
"-C", "cd $pwd; ipmo ./util/winget.psm1; InstallWinget"
2024-11-24 20:14:10 +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)
}