From a8ad457281d284bd528d45c8488f468d1b2212f0 Mon Sep 17 00:00:00 2001 From: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Date: Thu, 29 Aug 2024 22:54:48 +0200 Subject: [PATCH] [MicroWin] Add error details and messages --- functions/private/Invoke-WinUtilMicroWin-Helper.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 index f3ffbd9c5b..d1061d67f3 100644 --- a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 +++ b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 @@ -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 \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 } } @@ -106,6 +107,8 @@ function Remove-Packages { $_ -NotLike "*Wifi*" } + $failedCount = 0 + foreach ($pkg in $pkglist) { try { $status = "Removing $pkg" @@ -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 } } @@ -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 } }