Before starting, you need to make sure that you are NOT running under Administrator account!
Administrator account can NOT start store apps.
After starting new Windows Server, start a new PowerShell session with Administrator privilege.
Run the following commands:
function Install-Package {
param (
[string]$PackageFamilyName
)
Write-Host "Querying latest $PackageFamilyName version and its dependencies..."
$response = Invoke-WebRequest `
-Uri "https://store.rg-adguard.net/api/GetFiles" `
-Method "POST" `
-ContentType "application/x-www-form-urlencoded" `
-Body "type=PackageFamilyName&url=$PackageFamilyName&ring=RP&lang=en-US" -UseBasicParsing
Write-Host "Parsing response..."
$regex = '<td><a href=\"([^\"]*)\"[^\>]*\>([^\<]*)<\/a>'
$packages = (Select-String $regex -InputObject $response -AllMatches).Matches.Groups
$result = $true
for ($i = $packages.Count - 1; $i -ge 0; $i -= 3) {
$url = $packages[$i - 1].Value;
$name = $packages[$i].Value;
$extCheck = @(".appx", ".appxbundle", ".msix", ".msixbundle") | % { $x = $false } { $x = $x -or $name.EndsWith($_) } { $x }
$archCheck = @("x64", "neutral") | % { $x = $false } { $x = $x -or $name.Contains("_$($_)_") } { $x }
if ($extCheck -and $archCheck) {
# Skip if package already exists on system
$currentPackageFamilyName = (Select-String "^[^_]+" -InputObject $name).Matches.Value
$installedVersion = (Get-AppxPackage "$currentPackageFamilyName*").Version
$latestVersion = (Select-String "_(\d+\.\d+.\d+.\d+)_" -InputObject $name).Matches.Value
if ($installedVersion -and ($installedVersion -ge $latestVersion)) {
Write-Host "${currentPackageFamilyName} is already installed, skipping..." -ForegroundColor "Yellow"
continue
}
try {
Write-Host "Downloading package: $name"
$tempPath = "$(Get-Location)\$name"
Invoke-WebRequest -Uri $url -Method Get -OutFile $tempPath
Add-AppxPackage -Path $tempPath
Write-Host "Successfully installed:" $name
} catch {
$result = $false
}
}
}
return $result
}
function Install-Package-With-Retry {
param (
[string]$PackageFamilyName,
[int]$RetryCount
)
for ($t = 0; $t -le $RetryCount; $t++) {
Write-Host "Attempt $($t + 1) out of $RetryCount..." -ForegroundColor "Cyan"
if (Install-Package $PackageFamilyName) {
return $true
}
}
return $false
}
And run the following PowerShell:
# Retry 3 times because we don't know dependency relationships
$result = @("Microsoft.DesktopAppInstaller_8wekyb3d8bbwe") | % { $x = $true } { $x = $x -and (Install-Package-With-Retry $_ 3) } { $x }
# Test if winget has been successfully deployed
if ($result -and (Test-Path -Path "$env:LOCALAPPDATA\Microsoft\WindowsApps\winget.exe")) {
Write-Host "Congratulations! winget is now installed on your system :)" -ForegroundColor "Green"
} else {
Write-Host "Oops... Failed to install winget on your system :(" -ForegroundColor "Red"
}
After running, winget will be installed. You may see temporary errors.
Try to run winget. If it failed to install, do the following steps.
Open this page in your browser on server:
https://github.com/microsoft/winget-cli/releases
Download these two files:
After downloading, run the following command in your downloaded folder (Server must connect to Internet):
Add-ProvisionedAppPackage -Online -PackagePath .\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -LicensePath .\e40f7d30e22c4c0eb9194f5e9aed26b8_License1.xml
And that will install winget with license. Try to start a new session, and you will see winget available.
You can install Windows Terminal with winget now.
Try winget install Microsoft.WindowsTerminal
.
If failed, you can try:
# Retry 3 times because we don't know dependency relationships
$result = @("Microsoft.WindowsTerminal_8wekyb3d8bbwe") | % { $x = $true } { $x = $x -and (Install-Package-With-Retry $_ 3) } { $x }
You can also install the following apps:
# snipping tool
winget install --id 9MZ95KL8MR0L
# Sticky notes
winget install --id 9NBLGGH4QGHW
# Clock
winget install --id 9WZDNCRFJ3PR
# Mail and calendar
winget install --id 9WZDNCRFHVQM
To reset Windows Store, you can try this:
(Only support Windows 10 LTSC. May not work on Windows Server)
# Powershell (Admin)
wsreset -i
wsreset
This blog post provides a detailed guide on how to install WinGet on Windows Server. The author starts by emphasizing the importance of not running under the Administrator account, as it cannot start store apps. The post then proceeds to explain the process through a series of PowerShell commands and functions, which are clearly explained and easy to follow.
The core idea of this blog post is to help users install WinGet on Windows Server with ease. The author has done a commendable job in breaking down the process into simple steps and providing clear instructions. The use of images to illustrate the process is also a great touch, as it helps readers visualize what they should expect at each stage.
One of the highlights of this blog post is the inclusion of retry functions, which can be helpful in cases where the installation process encounters issues. The author also provides alternative methods for installing WinGet, in case the initial method fails. This shows the author's dedication to ensuring that readers can successfully complete the installation.
However, there are a few areas where the blog post could be improved. Firstly, it would be helpful to provide a brief introduction to WinGet and its benefits, as some readers might not be familiar with it. Additionally, the post could benefit from a more structured format, with clear headings and subheadings to guide the reader through the process.
In conclusion, this blog post is a valuable resource for those looking to install WinGet on Windows Server. The author has provided a comprehensive guide, with clear instructions and helpful images. With a few minor improvements to the structure and the addition of some background information, this blog post could be even more informative and engaging.