Update Invoke-MicroWin-Helper.ps1 (#2192)

Added Try-Catch block for AppX package removal
This commit is contained in:
CodingWonders 2024-06-28 16:42:48 +02:00 committed by GitHub
parent a510b52acb
commit 04130231ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -159,7 +159,13 @@ function Remove-ProvisionedPackages([switch] $keepSecurity = $false)
{
$status = "Removing Provisioned $($appx.PackageName)"
Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100)
Remove-AppxProvisionedPackage -Path $scratchDir -PackageName $appx.PackageName -ErrorAction SilentlyContinue
try {
Remove-AppxProvisionedPackage -Path $scratchDir -PackageName $appx.PackageName -ErrorAction SilentlyContinue
}
catch {
Write-Host "Application $($appx.PackageName) could not be removed"
continue
}
}
Write-Progress -Activity "Removing Provisioned Apps" -Status "Ready" -Completed
}