winget, a command line package manager, doesn't have a command line installer? ๐คฃ Now it does! ๐
- Requires PowerShell running with Administrator rights
- Compatible with:
- Windows 10 (Version 1809 or higher)
- Windows 11
- Server 2022
- Not compatible with:
- Server 2019 (winget not supported)
- Installs winget-cli directly from PowerShell
- Always fetches the latest
winget
version - Automatically verifies OS compatibility
- Determines and installs the appropriate prerequisites based on OS version
- Updates existing prerequisites to their latest versions
- Supports x86/x64 and arm/arm64 architectures
- Allows bypassing of existing
winget
installation verification through$Force
session variable or-Force
parameter
- Identifies processor architecture to decide which prerequisites are needed (x86/x64 or arm/arm64)
- Checks Windows OS version for compatibility (Windows 10, Windows 11, Server 2022)
- Verifies Windows 10 release ID for compatibility (must be 1809 or newer)
- Manages prerequisite versions based on OS:
- Forces older versions on Windows 10 and Server 2022
- Uses latest versions from Microsoft Store on Windows 11
- Executes winget registration command on Windows 10
- VCLibs is installed straight from the appx package
- Primary method
- If Windows 10 or Server 2022, alternate method is forced so that older version of prerequisite is used (newer version is not compatible)
- Determines the direct download URL for the appx package
- Installs appx package using direct download URL
- Alternate method (if primary download URL fails)
- Uses version 14.00 for compatibility reasons
- Installs appx package using aka.ms URL
- Primary method
- UI.Xaml is installed
- Primary method
- If Windows 10 or Server 2022, alternate method is forced so that older version of prerequisite is used (newer version is not compatible)
- Determines the direct download URL for the appx package
- Installs appx package using direct download URL
- Alternate method (if primary download URL fails)
- Uses version 2.7.3 for compatibility reasons
- Downloads nupkg package using nuget.org URL
- Extracts appx package from nupkg package
- Installs appx package using extracted appx package
- Primary method
- winget-cli is then installed using the latest version from GitHub
- Machine & User PATH variables are adjusted to include WindowsApps folder if needed
Note: For a stable experience, use one of the methods listed below (#1, #2, or #3) to fetch the latest version. Using the version directly from the GitHub repository is not advised, as it could be under active development and not fully stable.
Open PowerShell as Administrator and type
Install-Script winget-install -Force
Follow the prompts to complete the installation (you can tap A
to accept all prompts or Y
to select them individually.
Note: -Force
is optional but recommended, as it will force the script to update if it is outdated. If you do not use -Force
, it will not overwrite the script if outdated.
winget-install
The script is published on PowerShell Gallery under winget-install
.
If you want to trust PSGallery so you aren't prompted each time you run this command, or if you're scripting this and want to ensure the script isn't interrupted the first time it runs...
Install-PackageProvider -Name "NuGet" -Force
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
The URL asheroto.com/winget always redirects to the latest code-signed release of the script.
irm asheroto.com/winget | iex
If PowerShell closes right away, it's likely because winget is already on your system. To override this and run the script again, set the $Force
session variable to $true
prior to executing the command. Note that the -Force
parameter won't work in this context; it's only effective when the script is called using winget-install
. If you're using the one-line command, you'll need to use the $Force
session variable instead.
$Force = $true
irm asheroto.com/winget | iex
- Download the latest winget-install.ps1 from Releases
- Run the script with
.\winget-install.ps1
No parameters are required to run the script, but there are some optional parameters to use if needed.
Parameter | Required | Description |
---|---|---|
-DebugMode |
No | Enables debug mode, which shows additional information for debugging. |
-DisableCleanup |
No | Disables cleanup of the script and prerequisites after installation. |
-Force |
No | Ensures installation of winget and its dependencies, even if already present. |
-CheckForUpdate |
No | Checks if there is an update available for the script. |
-UpdateSelf |
No | Updates the script to the latest version. |
-Version |
No | Displays the version of the script. |
-Help |
No | Displays the full help information for the script. |
- Before releasing a new version, the script is tested on a clean install of Windows 10 22H2, Server 2022 21H2, and Windows 11 22H2
- If you run into an issue, please ensure your system is compatible & fully updated
- Try running
winget-install
again, sometimes the script will fail due to a temporary issue with the prerequisite server URLs - Try using the
-DebugMode
and-DisableCleanup
parameters to see if it provides any additional information - Try installing winget manually to see if the issue exists with winget itself
- If the issue occurs when installing winget manually, please open an issue on the winget-cli repo (unrelated to this script)
- Check the winget-cli Troubleshooting Guide
- If the problem only occurs when using this script, please open an issue here
If you're like to help develop this project: fork the repo. ๐