winget.ps1
· 483 B · PowerShell
Raw
# Get the download URL of the latest winget installer from GitHub:
$API_URL = "https://api.github.com/repos/microsoft/winget-cli/releases/latest"
$DOWNLOAD_URL = $(Invoke-RestMethod $API_URL).assets.browser_download_url |
Where-Object {$_.EndsWith(".msixbundle")}
# Download the installer:
Invoke-WebRequest -URI $DOWNLOAD_URL -OutFile winget.msixbundle -UseBasicParsing
# Install winget:
Add-AppxPackage winget.msixbundle
# Remove the installer:
Remove-Item winget.msixbundle
| 1 | # Get the download URL of the latest winget installer from GitHub: |
| 2 | $API_URL = "https://api.github.com/repos/microsoft/winget-cli/releases/latest" |
| 3 | $DOWNLOAD_URL = $(Invoke-RestMethod $API_URL).assets.browser_download_url | |
| 4 | Where-Object {$_.EndsWith(".msixbundle")} |
| 5 | |
| 6 | # Download the installer: |
| 7 | Invoke-WebRequest -URI $DOWNLOAD_URL -OutFile winget.msixbundle -UseBasicParsing |
| 8 | |
| 9 | # Install winget: |
| 10 | Add-AppxPackage winget.msixbundle |
| 11 | |
| 12 | # Remove the installer: |
| 13 | Remove-Item winget.msixbundle |