[MicroWin] Add try-catch block for AppX packages (#2560)

This commit is contained in:
CodingWonders 2024-08-14 21:31:24 +02:00 committed by GitHub
parent b0d54e41ad
commit 4d2ea15e19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -132,6 +132,8 @@ function Remove-ProvisionedPackages() {
.EXAMPLE
Remove-ProvisionedPackages
#>
try
{
$appxProvisionedPackages = Get-AppxProvisionedPackage -Path "$($scratchDir)" | Where-Object {
$_.PackageName -NotLike "*AppInstaller*" -AND
$_.PackageName -NotLike "*Store*" -and
@ -153,7 +155,6 @@ function Remove-ProvisionedPackages() {
$_.PackageName -NotLike "*Gaming*" -and
$_.PackageName -NotLike "*Extension*" -and
$_.PackageName -NotLike "*SecHealthUI*"
}
$counter = 0
@ -169,6 +170,12 @@ function Remove-ProvisionedPackages() {
}
Write-Progress -Activity "Removing Provisioned Apps" -Status "Ready" -Completed
}
catch
{
# This can happen if getting AppX packages fails
Write-Host "Unable to get information about the AppX packages. MicroWin processing will continue, but AppX packages will not be processed"
}
}
function Copy-ToUSB([string]$fileToCopy) {
foreach ($volume in Get-Volume) {