Microsoft's documentation explains how winget can be installed through the Microsoft Store. But it is also possible to install it with PowerShell. The following script shows how this can be done. To run it, type "PowerShell" into the Start menu, right-click on the top result and select "Run as administrator". Then paste the script into the console and press Enter.
# 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
If you get an error that the framework "Microsoft.UI.Xaml.2.7" could not be found, then you can use the following commands to install it:
Invoke-WebRequest ` -URI https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.3 ` -OutFile xaml.zip -UseBasicParsing New-Item -ItemType Directory -Path xaml Expand-Archive -Path xaml.zip -DestinationPath xaml Add-AppxPackage -Path "xaml\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx" Remove-Item xaml.zip Remove-Item xaml -Recurse
If you then get another error that the framework "Microsoft.VCLibs.140.00.UWPDesktop" could not be found, then you can additionally use the following commands to install it:
Invoke-WebRequest ` -URI https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx ` -OutFile UWPDesktop.appx -UseBasicParsing Add-AppxPackage UWPDesktop.appx Remove-Item UWPDesktop.appx
Then, repeat the initial commands.
Once you have followed the above steps, you can use
winget
on the command line. For example, to update
PowerShell:
winget install --id Microsoft.Powershell --source winget
Remember to again run this with administrative privileges. If you
want to execute it in PowerShell itself, prefix the line with an
ampersand &
.