Fix non-functioning winget
install script
This commit is contained in:
parent
554f3c9a63
commit
306d9afd50
1 changed files with 6 additions and 34 deletions
|
@ -2,38 +2,10 @@
|
|||
. "$PSScriptRoot/../../Scripts/Context.ps1";
|
||||
|
||||
function Install-Winget {
|
||||
param([Context] $context)
|
||||
Write-Host "Installing winget";
|
||||
$namePattern = "*Desktop*Installer*";
|
||||
[System.Collections.Generic.List[string]] $packages = @();
|
||||
$versions = Get-AppxPackage -AllUsers "$namePattern";
|
||||
|
||||
if ($versions.Count -gt 0) {
|
||||
if (-not $(Get-Command sqlite3)) {
|
||||
$packages.Add("sqlite");
|
||||
}
|
||||
|
||||
if ($packages.Count -gt 0) {
|
||||
Write-Host "Installing prequisites for uninstalling winget";
|
||||
|
||||
foreach ($package in $packages) {
|
||||
choco install -y "$package";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($version in $versions) {
|
||||
sqlite3 `
|
||||
"$env:ProgramData\Microsoft\Windows\AppRepository\StateRepository-Machine.srd" `
|
||||
"UPDATE Package SET IsInbox = 0 WHERE PackageFullName = '$($version.PackageFullName)'";
|
||||
}
|
||||
|
||||
Get-AppxPackage -AllUsers "$namePattern" | Remove-AppxPackage -AllUsers;
|
||||
|
||||
Get-AppxProvisionedPackage -Online | `
|
||||
Where-Object { $_.DisplayName -like "$namePattern" } | `
|
||||
Remove-AppxProvisionedPackage -Online;
|
||||
}
|
||||
|
||||
choco install -y winget;
|
||||
$downloadLink = "https://github.com/microsoft/winget-cli/releases/latest/download/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle";
|
||||
$file = New-TemporaryFile;
|
||||
$file = Rename-Item $file "$file.msixbundle";
|
||||
Invoke-WebRequest "$downloadLink" -OutFile "$file";
|
||||
Add-AppxPackage "$file";
|
||||
Remove-Item $file;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue