Skip to content

Commit

Permalink
[MicroWin] Add error details and messages (#2647)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingWonders authored Aug 30, 2024
1 parent a397f20 commit 2a0d121
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions functions/private/Invoke-WinUtilMicroWin-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function Remove-Features() {
Write-Host "You can re-enable the disabled features at any time, using either Windows Update or the SxS folder in <installation media>\Sources."
} catch {
Write-Host "Unable to get information about the features. MicroWin processing will continue, but features will not be processed"
Write-Host "Error information: $($_.Exception.Message)" -ForegroundColor Yellow
}
}

Expand Down Expand Up @@ -106,6 +107,8 @@ function Remove-Packages {
$_ -NotLike "*Wifi*"
}

$failedCount = 0

foreach ($pkg in $pkglist) {
try {
$status = "Removing $pkg"
Expand All @@ -114,12 +117,18 @@ function Remove-Packages {
} catch {
# This can happen if the package that is being removed is a permanent one, like FodMetadata
Write-Host "Could not remove OS package $($pkg)"
$failedCount += 1
continue
}
}
Write-Progress -Activity "Removing Apps" -Status "Ready" -Completed
if ($failedCount -gt 0)
{
Write-Host "Some packages could not be removed. Do not worry: your image will still work fine. This can happen if the package is permanent or has been superseded by a newer one."
}
} catch {
Write-Host "Unable to get information about the packages. MicroWin processing will continue, but packages will not be processed"
Write-Host "Error information: $($_.Exception.Message)" -ForegroundColor Yellow
}
}

Expand Down Expand Up @@ -175,6 +184,7 @@ function Remove-ProvisionedPackages() {
{
# 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"
Write-Host "Error information: $($_.Exception.Message)" -ForegroundColor Yellow
}
}

Expand Down

0 comments on commit 2a0d121

Please sign in to comment.