Skip to content

Instantly share code, notes, and snippets.

@erwinkersten
Last active June 8, 2026 03:28
Show Gist options
  • Select an option

  • Save erwinkersten/626ed456c1bd84fd5e023b081d6d450e to your computer and use it in GitHub Desktop.

Select an option

Save erwinkersten/626ed456c1bd84fd5e023b081d6d450e to your computer and use it in GitHub Desktop.
Install WIndows Package Manager (winget) on Windows Server 2022

Install Windows Package Manager (winget) on Windows Server 2022

Update: the easiest current method is to use the community winget-install script from PowerShell Gallery. This script installs WinGet and required dependencies automatically.

Run the following from an elevated PowerShell session:

Install-Script -Name winget-install -Force
winget-install -Force

After installation, open a new PowerShell session and verify:

winget --info

Notes:

  • Install-Script -Name winget-install -Force installs or updates the helper script from PowerShell Gallery.
  • winget-install -Force runs the installer and forces the install/repair flow even if WinGet appears to be present already.
  • You may be prompted to install the NuGet provider or trust PowerShell Gallery the first time.
  • For production, restricted, or offline environments, review the script and consider mirroring/pinning it through your own trusted repository before use.

The manual method below is kept as a fallback for environments where PowerShell Gallery access is unavailable or where third-party scripts are not allowed.

Manual fallback: install from the official Microsoft WinGet release assets

Use this method if you do not want to use a third-party helper script, or if PowerShell Gallery access is not available.

Run this from Windows PowerShell as Administrator. PowerShell 7 is not recommended for this flow because the Appx cmdlets are Windows PowerShell cmdlets.

$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
$WorkDir = Join-Path $env:TEMP 'winget-install'
$DepsDir = Join-Path $WorkDir 'DesktopAppInstaller_Dependencies'
New-Item -ItemType Directory -Force -Path $WorkDir | Out-Null

## Get latest stable WinGet release from GitHub

$Release = Invoke-RestMethod -Uri 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'

$MsixBundle = $Release.assets |
    Where-Object { $_.name -eq 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle' } |
    Select-Object -First 1

$DependenciesZip = $Release.assets |
    Where-Object { $_.name -eq 'DesktopAppInstaller_Dependencies.zip' } |
    Select-Object -First 1

$LicenseFile = $Release.assets |
    Where-Object { $_.name -like '*_License1.xml' } |
    Select-Object -First 1

if (-not $MsixBundle -or -not $DependenciesZip -or -not $LicenseFile) {
    throw 'Could not find all required WinGet release assets.'
}

$MsixBundlePath = Join-Path $WorkDir 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle'
$DependenciesZipPath = Join-Path $WorkDir 'DesktopAppInstaller_Dependencies.zip'
$LicensePath = Join-Path $WorkDir 'license.xml'

## Download WinGet, dependencies, and license

Invoke-WebRequest -Uri $MsixBundle.browser_download_url -OutFile $MsixBundlePath
Invoke-WebRequest -Uri $DependenciesZip.browser_download_url -OutFile $DependenciesZipPath
Invoke-WebRequest -Uri $LicenseFile.browser_download_url -OutFile $LicensePath

## Extract and install dependencies

Expand-Archive -Path $DependenciesZipPath -DestinationPath $DepsDir -Force

## Windows Server 2022 is normally x64. Adjust if needed for another architecture.

$Architecture = 'x64'
$DependencyPath = Join-Path $DepsDir $Architecture

Get-ChildItem -Path $DependencyPath -File |
    Where-Object { $_.Extension -in '.appx', '.msix' } |
    ForEach-Object {
        Add-AppxPackage -Path $_.FullName
    }

## Provision App Installer / WinGet
Add-AppxProvisionedPackage -Online -PackagePath $MsixBundlePath -LicensePath $LicensePath

## Register the package for the current user if winget is not immediately available
Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe

## Verify
winget --info
@samskyworks

Copy link
Copy Markdown

Download License file, With version bump also update the license file name (see assets)

Invoke-WebRequest -Uri https://github.com/microsoft/winget-cli/releases/download/v$env:WinGetVer/fb2830f66c95424aa35457b05e88998a_License1.xml -outfile license.xml

Invoke-WebRequest : The request was aborted: The connection was closed unexpectedly.
At line:1 char:1

  • Invoke-WebRequest -Uri https://github.com/microsoft/winget-cli/releas ...
  •   + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
     eption
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
    

@tolache

tolache commented May 29, 2026

Copy link
Copy Markdown

What worked for me:

Install-Script winget-install -Force
winget-install -Force

Confirmed. This is what works, and this is all you need.

@hueldoeu

Copy link
Copy Markdown

What worked for me:

Install-Script winget-install -Force
winget-install -Force

Confirmed. This is what works, and this is all you need.

hello, would you be so kind and summarize all the commands i need to type into windows server 2022 to have winget installed there?

sadly unigetUI dropped predelivered winget-support

@fdcastel

Copy link
Copy Markdown

@erwinkersten as a kind suggestion: what about updating the original post of this gist?

It seems to be a frequent Google search target πŸ˜‰

@hueldoeu

Copy link
Copy Markdown

@erwinkersten as a kind suggestion: what about updating the original post of this gist?

It seems to be a frequent Google search target πŸ˜‰

we would like to use windows server 2025 where winget is already included and even our super-old x-ray program works, but out dental office software doesn't work on windows server 2025. we have to pay for a conversion into a docker-container (putting garbage more than 35 years old inside a docker-container and getting paid 6000 € per license for it). and since winget is a nice feature (i can also try scoop or chocolatey) although there is not must software on the SOHO-On-Prem-Server (tower) it's not bad to use it and work with it on windows server 2022.

@erwinkersten

Copy link
Copy Markdown
Author

Thanks everyone for the suggestions, confirmations, and additional troubleshooting details.

I have updated the original gist to reflect the current recommendations:

  • added the simpler Install-Script -Name winget-install -Force / winget-install -Force approach as the recommended option;
  • updated the manual fallback to use the latest WinGet release assets;
  • added handling for the newer dependency package;
  • added the package registration step for cases where WinGet installs but is not immediately available;
  • kept notes for restricted, production, and offline environments.

Special thanks to @bacloud22, @kosikond, @fdcastel, @stanthewizzard, @spoonwzd, @gjonn, @Jalmenara, @flakd, @kalaklanar, @soulflyman, @lighthouseofthenight, @rexmorgan89, @samskyworks, @tolache, and @hueldoeu for pointing out improvements, reporting what worked or failed, and confirming the simpler approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment