Skip to content

Instantly share code, notes, and snippets.

@erwinkersten
Last active September 17, 2025 21:23
Show Gist options
  • Save erwinkersten/626ed456c1bd84fd5e023b081d6d450e to your computer and use it in GitHub Desktop.
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

  1. Download and install microsoft-ui-xaml
  2. Download WinGet an License file
  3. Install WinGet with License

Execute the following in Windows PowerShell (PowerShell 7 doesn't support the Appx module)

#Update versions, see https://github.com/microsoft/microsoft-ui-xaml/releases (grab Microsoft.UI.Xaml Winget may require a specific version) 
Invoke-WebRequest -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx -outfile Microsoft.UI.Xaml.appx
Add-AppxPackage -Path .\Microsoft.UI.Xaml.appx

# Select the Winversion you want to install, see https://github.com/microsoft/winget-cli/releases
# set the version with $env:WinGetVer

$env:WinGetVer=1.8.1911 

# 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


# Download Winget, version bump update als the msixbundle file
Invoke-WebRequest -Uri https://github.com/microsoft/winget-cli/releases/download/v$env:WinGetVer/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -outfile Microsoft.DesktopAppInstaller.WinGet.appx
# Install WingetWith License
Add-AppxProvisionedPackage -Online -PackagePath .\Microsoft.DesktopAppInstaller.WinGet.appx -LicensePath .\license.xml
```
@bacloud22
Copy link

image

@kosikond
Copy link

kosikond commented Sep 4, 2024

I got it working with release version 1.8.1911 instead of 1.8.1791

@erwinkersten
Copy link
Author

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

@kosikond
Copy link

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

# 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

# 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
Copy link

spoonwzd commented Oct 1, 2024

Same. Got it all to install, but nada.

@gjonn
Copy link

gjonn commented Oct 2, 2024

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

Note I got
0x803fb104 : unknown error

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

@fdcastel
Copy link

fdcastel commented Mar 4, 2025

What worked for me:

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

@Jalmenara
Copy link

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

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

@flakd
Copy link

flakd commented Jun 14, 2025

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

Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force

@stanthewizzard
Copy link

With win 2025 no more issues

@kalaklanar
Copy link

kalaklanar commented Aug 21, 2025

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

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

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

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

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

@hueldoeu
Copy link

hueldoeu commented Sep 9, 2025

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

@kalaklanar
Copy link

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

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