Logging optimiert

This commit is contained in:
Patrick Asmus
2026-07-05 21:19:58 +02:00
parent fbe28fc6bb
commit 2023869e6f

View File

@@ -9,9 +9,9 @@ Author: Patrick Asmus
Web: https://www.cleveradmin.de
Repository: https://git.techniverse.net/scriptos/windows-updater.git
License: MIT
Version: 2.0.0
Version: 2.0.1
Datum: 05.07.2026
Modifiaktione: Neuaufbau, viele neue Funktionen, verbesserte Fehlerbehandlung, optimierte Logik, erweiterte Benachrichtigungsoptionen, Winget-Integration, History-Export in CSV/XLSX, Pre/Post Hooks, Reboot-Kontrolle und mehr.
Modifiaktione: Logging optimiert
#####################################################
#>
@@ -701,7 +701,14 @@ function Install-PendingUpdates {
$resultArray = @($results)
foreach ($r in $resultArray) {
# PSWindowsUpdate returns multiple objects per update (one per phase: search, download, install).
# Group by KB and keep only the last (final) result per update.
$grouped = $resultArray | Group-Object -Property KB
$deduplicated = foreach ($group in $grouped) {
$group.Group | Select-Object -Last 1
}
foreach ($r in $deduplicated) {
$sizeStr = if ($r.Size) { "{0:N2} MB" -f ($r.Size / 1MB) } else { "N/A" }
$resultStr = if ($r.Result) { $r.Result.ToString() } else { $r.Status.ToString() }
$kbStr = if ($r.KB) { $r.KB } else { "N/A" }
@@ -720,7 +727,7 @@ function Install-PendingUpdates {
Add-UpdateHistoryEntry -KB $kbStr -Title $r.Title -Size $sizeStr -Result $resultStr
}
$failed = $resultArray | Where-Object { $_.Result -and $_.Result.ToString() -notmatch "Install|Success" }
$failed = $deduplicated | Where-Object { $_.Result -and $_.Result.ToString() -notmatch "Install|Success" }
if ($failed -and $retryCount -gt 0) {
Write-Log "Retrying $(@($failed).Count) failed update(s)..." -Level WARN
foreach ($f in $failed) {