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
@bacloud22

Copy link
Copy Markdown

image

@kosikond

kosikond commented Sep 4, 2024

Copy link
Copy Markdown

I got it working with release version 1.8.1911 instead of 1.8.1791

@erwinkersten

Copy link
Copy Markdown
Author

@bacloud23: updated the gist to use a variable, and @kosikond: thanks for the confirmation.

@kosikond

Copy link
Copy Markdown

I had to hardcode the version 1.8.1911 in the Invoke-WebRequest, otherwise with $env:winGetVer - out-of-the-box powershell.exe policy caused error with the env var and required managing Trusted Zones/firewall

Also the license1.xml file URI for v1.8.1911 is https://github.com/microsoft/winget-cli/releases/download/v1.8.1911/76fba573f02545629706ab99170237bc_License1.xml

@fdcastel

Copy link
Copy Markdown
# Select the version you want to install, see https://github.com/microsoft/winget-cli/releases
$WinGetVer='1.8.1911'
$WinGetLicenseFile='76fba573f02545629706ab99170237bc_License1.xml'

# https://stackoverflow.com/questions/28682642/powershell-why-is-using-invoke-webrequest-much-slower-than-a-browser-download#
$ProgressPreference = 'SilentlyContinue'

# Download and install Microsoft.UI.Xaml
Invoke-WebRequest -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx -OutFile $env:TEMP\Microsoft.UI.Xaml.appx
Add-AppxPackage -Path $env:TEMP\Microsoft.UI.Xaml.appx

# Download and install Microsoft.DesktopAppInstaller.WinGet
Invoke-WebRequest -Uri "https://github.com/microsoft/winget-cli/releases/download/v$WinGetVer/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -OutFile $env:TEMP\Microsoft.DesktopAppInstaller.WinGet.appx
Invoke-WebRequest -Uri "https://github.com/microsoft/winget-cli/releases/download/v$WinGetVer/$WinGetLicenseFile" -OutFile $env:TEMP\license.xml
Add-AppxProvisionedPackage -Online -PackagePath $env:TEMP\Microsoft.DesktopAppInstaller.WinGet.appx -LicensePath $env:TEMP\license.xml

@stanthewizzard

Copy link
Copy Markdown
# Select the version you want to install, see https://github.com/microsoft/winget-cli/releases
$WinGetVer='1.8.1911'
$WinGetLicenseFile='76fba573f02545629706ab99170237bc_License1.xml'

# https://stackoverflow.com/questions/28682642/powershell-why-is-using-invoke-webrequest-much-slower-than-a-browser-download#
$ProgressPreference = 'SilentlyContinue'

# Download and install Microsoft.UI.Xaml
Invoke-WebRequest -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx -OutFile $env:TEMP\Microsoft.UI.Xaml.appx
Add-AppxPackage -Path $env:TEMP\Microsoft.UI.Xaml.appx

# Download and install Microsoft.DesktopAppInstaller.WinGet
Invoke-WebRequest -Uri "https://github.com/microsoft/winget-cli/releases/download/v$WinGetVer/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -OutFile $env:TEMP\Microsoft.DesktopAppInstaller.WinGet.appx
Invoke-WebRequest -Uri "https://github.com/microsoft/winget-cli/releases/download/v$WinGetVer/$WinGetLicenseFile" -OutFile $env:TEMP\license.xml
Add-AppxProvisionedPackage -Online -PackagePath $env:TEMP\Microsoft.DesktopAppInstaller.WinGet.appx -LicensePath $env:TEMP\license.xml

Sadly
Winget is not recognized

What did I do wrong ?

Thanks

@spoonwzd

spoonwzd commented Oct 1, 2024

Copy link
Copy Markdown

Same. Got it all to install, but nada.

@gjonn

gjonn commented Oct 2, 2024

Copy link
Copy Markdown

Screenshot 2024-10-02 at 3 03 11β€―PM

Check App Readiness logs in Event Viewer. You might need to install dependencies:

Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -Method Get -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx
Add-AppxPackage -Path .\Microsoft.VCLibs.x64.14.00.Desktop.appx

@stanthewizzard

Copy link
Copy Markdown

Note I got
0x803fb104 : unknown error

with winget install 9msmlrh6lzf3 --accept-source-agreements --accept-package-agreements (notepads app)

@fdcastel

fdcastel commented Mar 4, 2025

Copy link
Copy Markdown

What worked for me:

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

@Jalmenara

Copy link
Copy Markdown
Install-Script winget-install -Force
winget-install -Force

Thank you @fdcastel ! These two lines simply worked for me (even without the -Force)

@flakd

flakd commented Jun 14, 2025

Copy link
Copy Markdown

Thank you.... You can also try running this first:

Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force

@stanthewizzard

Copy link
Copy Markdown

With win 2025 no more issues

@kalaklanar

kalaklanar commented Aug 21, 2025

Copy link
Copy Markdown

A slight update for the latest versions (it's a lot more reliable if you past it in the command line window and not run it as a script for some reason:

# Select the version you want to install, see https://github.com/microsoft/winget-cli/releases
$WinGetVer='1.11.430'
$WinGetLicenseFile='e53e159d00e04f729cc2180cffd1c02e_License1.xml'

# https://stackoverflow.com/questions/28682642/powershell-why-is-using-invoke-webrequest-much-slower-than-a-browser-download#
$ProgressPreference = 'SilentlyContinue'

# NuGet is also a requirement
# Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
$sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$targetNugetExe = "$rootPath\nuget.exe"
Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe
Set-Alias nuget $targetNugetExe -Scope Global -Verbose

# Download and install Microsoft.UI.Xaml
Invoke-WebRequest -Uri "https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx" -OutFile $env:TEMP\Microsoft.UI.Xaml.appx
Add-AppxPackage -Path $env:TEMP\Microsoft.UI.Xaml.appx

# Download and install Microsoft.DesktopAppInstaller.WinGet
Invoke-WebRequest -Uri "https://github.com/microsoft/winget-cli/releases/download/v$WinGetVer/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -OutFile $env:TEMP\Microsoft.DesktopAppInstaller.WinGet.appx
Invoke-WebRequest -Uri "https://github.com/microsoft/winget-cli/releases/download/v$WinGetVer/$WinGetLicenseFile" -OutFile $env:TEMP\license.xml
Add-AppxProvisionedPackage -Online -PackagePath $env:TEMP\Microsoft.DesktopAppInstaller.WinGet.appx -LicensePath $env:TEMP\license.xml

@soulflyman

Copy link
Copy Markdown

I don't get it, I have four Windows Server 2022 (21H2 Build 20348.3692).
Two physical machines and two virtual machines.
The commands from @kalaklanar worked on the physical machines but not on the virtual machines.

All the Commands run without any error but winget is not available on the machine after the installation.
πŸ€·β€β™‚οΈ

@kalaklanar

Copy link
Copy Markdown

That's good to know. I had 4VMs, one KVM, on VMware and 2 on a vendor using appstream. The first 2 were trial Windows installs, and they worked. The last 2 didn't work after I posted that, with the same symptoms you described. Was there anything special about your failing VMs?

@soulflyman

Copy link
Copy Markdown

Nothing special that I'm aware of. One was nearly a half year old, and the other was set up last week. Both are on the same patch level as the physical servers.

@soulflyman

Copy link
Copy Markdown

During the search for a solution, I found this script, and it worked!
https://github.com/asheroto/winget-install

@hueldoeu

hueldoeu commented Sep 9, 2025

Copy link
Copy Markdown

i just have installed unigetUI and don't need winget.

@kalaklanar

Copy link
Copy Markdown

I just want to make a note that somewhere in my frustration in getting this working on my las tstubborn machine. For this last mile I ran:
Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe

@lighthouseofthenight

Copy link
Copy Markdown

I usually install like this, works fine, just don't miss new dependencies introduced in recent versions. Also install for current user if app readiness services are not doing it for you:

powershell
cd ~\Downloads
Start-BitsTransfer -Source "https://github.com/microsoft/winget-cli/releases/latest/download/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -Destination "~\Downloads\WinGet.msixbundle"
Start-BitsTransfer -Source "https://github.com/microsoft/winget-cli/releases/latest/download/DesktopAppInstaller_Dependencies.zip" -Destination "~\Downloads\DesktopAppInstaller_Dependencies.zip"
Start-BitsTransfer -Source "https://github.com/microsoft/winget-cli/releases/latest/download/e53e159d00e04f729cc2180cffd1c02e_License1.xml" -Destination "~\Downloads\license.xml"
Expand-Archive -Path "~\Downloads\DesktopAppInstaller_Dependencies.zip"
Add-AppxPackage "~\Downloads\DesktopAppInstaller_Dependencies\x64\Microsoft.UI.Xaml*x64.appx"
Add-AppxPackage "~\Downloads\DesktopAppInstaller_Dependencies\x64\Microsoft.VCLibs*x64.appx"
Add-AppxPackage "~\Downloads\DesktopAppInstaller_Dependencies\x64\Microsoft.WindowsAppRuntime*x64.appx"
Add-AppxProvisionedPackage -Online -PackagePath .\WinGet.msixbundle -LicensePath .\license.xml
Get-AppPackage *Microsoft.DesktopAppInstaller*|select Name,PackageFullName
winget --info
Remove-Item -Path "~\Downloads\WinGet.msixbundle", "~\Downloads\DesktopAppInstaller_Dependencies.zip", "~\Downloads\DesktopAppInstaller_Dependencies", "~\Downloads\license.xml" -Recurse -Force

@rexmorgan89

Copy link
Copy Markdown

@lighthouseofthenight has solved this once and for all. Great job.

@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