$ErrorActionPreference = 'Stop' $info = Get-ComputerInfo -Property @("WindowsInstallationType", "WindowsVersion") if ($info.WindowsInstallationType -ne "Server") { write-host "This script is only intended for use on Windows Server because installation of winget is not officially supported there!" return } # Microsoft.UI.Xaml: https://www.nuget.org/packages/Microsoft.UI.Xaml # Microsoft.VCLibs: https://docs.microsoft.com/troubleshoot/developer/visualstudio/cpp/libraries/c-runtime-packages-desktop-bridge#how-to-install-and-update-desktop-framework-packages # WinGet: https://github.com/microsoft/winget-cli#manually-update # update links manually $msuixaml = "https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.1" $vclibs = "https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx" $winget = "https://github.com/microsoft/winget-cli/releases/download/v1.2.10271/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" $wingetLicense = "https://github.com/microsoft/winget-cli/releases/download/v1.2.10271/b0a0692da1034339b76dce1c298a1e42_License1.xml" $msuixamlPath = "$env:tmp/microsoft.ui.xaml.zip" $msuixamlPathExtracted = "$env:tmp/microsoft-ui-xaml" $vclibsPath = "$env:tmp/Microsoft.VCLibs.Desktop.appx" $wingetPath = "$env:tmp/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" $wingetLicensePath = "$env:tmp/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.license.xml" Invoke-WebRequest -UseBasicParsing -Uri $msuixaml -OutFile $msuixamlPath Expand-Archive -LiteralPath $msuixamlPath -DestinationPath $msuixamlPathExtracted -Force $msuixamlExtracted = Get-ChildItem -File -LiteralPath "$msuixamlPathExtracted/tools/AppX/x64/Release" | Where-Object { [regex]::Match($_.Extension, "^\.(appx|msix)(bundle)?$") } | Select-Object -ExpandProperty FullName -First 1 Add-AppxPackage -Path $msuixamlExtracted Invoke-WebRequest -UseBasicParsing -Uri $vclibs -OutFile $vclibsPath Add-AppxPackage -Path $vclibsPath Invoke-WebRequest -UseBasicParsing -Uri $winget -OutFile $wingetPath Invoke-WebRequest -UseBasicParsing -Uri $wingetLicense -OutFile $wingetLicensePath Add-AppxPackage -Path $wingetPath