Skip to content

Instantly share code, notes, and snippets.

@erwinkersten
Last active August 16, 2026 13:21
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
@FDBTech

FDBTech commented Aug 14, 2026

Copy link
Copy Markdown

Has anyone made a Windows Server 2022 image with WinGet installed? I tried using the script and the manual steps when creating a Windows 11 Enterprise LTSC image (WinGet is not included in LTSC) and sysprep fails with SYSPRP Package Microsoft.Winget.Source_2026.814.716.1_neutral__8wekyb3d8bbwe was installed for a user, but not provisioned for all users. This package will not function properly in the sysprep image. Before I attempt to do the same thing with a Windows Server 2022 image, was just curious if anyone has tried.

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