coff33ninja / winget-install-fork

Install winget tool using PowerShell! Prerequisites automatically installed. Works on Windows 10/11 and Server 2022.

Home Page:https://bit.ly/winget-install

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

winget Windows 10 GitHub Release Date - Published_At GitHub Downloads - All Releases GitHub Sponsor Ko-Fi Button

Install winget from PowerShell

winget, a command line package manager, doesn't have a command line installer? 🤣 Now it does! 😊

Features

  • Install winget-cli straight from PowerShell
  • Always gets the latest version of winget
  • Works on Windows 10, Windows 11, Server 2022
  • Does not work on Server 2019
  • winget (and therefore this script) requires "Windows 10 version 1809 or newer (LTSC included)"
  • Script automatically determines if your OS version is compatible
  • Script automatically determines which version of the prerequisites to install based on your OS version
  • If prerequisites are already installed, they will be updated to the latest version
  • If Windows 10 or Server 2022, script will force the use of older versions of prerequisites (newer versions are not compatible)
  • If Windows 11, script will use the latest versions of prerequisites from the Microsoft Store

Script Functionality

  • Processor architecture determined for prerequisites (x86/x64 or arm/arm64)
  • Windows OS version determined to confirm compatibility (Windows 10, Windows 11, Server 2022)
  • If Windows 10, release ID determined to confirm compatibility (1809 or newer)
  • 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
  • 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
  • winget-cli is then installed using the latest version from GitHub
  • Machine & User PATH variables are adjusted to include WindowsApps folder if needed

Setup

Method 1 - PowerShell Gallery

Note: please use the latest version using Install-Script or the PS1 file from Releases, the version on GitHub itself may be under development and not work properly.

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.

The script is published on PowerShell Gallery under winget-install.

Tip - How to trust PSGallery

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

Method 2 - Download Locally and Run

Usage

In PowerShell, type

winget-install

Parameters

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.
-Version No Displays the version of the script.
-Help No Displays the full help information for the script.

Troubleshooting

  • 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

Contributing

If you're like to help develop this project: fork the repo. 😊

About

Install winget tool using PowerShell! Prerequisites automatically installed. Works on Windows 10/11 and Server 2022.

https://bit.ly/winget-install

License:GNU General Public License v3.0


Languages

Language:PowerShell 100.0%