dist/WU-SizeDiag.ps1
|
# Windows Update Size Diagnostic Script # Dumps detailed info about pending updates to understand the 91 GB mystery Write-Host "`n=== Windows Update Size Diagnostic ===" -ForegroundColor Cyan Write-Host "Running on: $env:COMPUTERNAME" Write-Host "Date: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')`n" try { $updateSession = New-Object -ComObject Microsoft.Update.Session $updateSearcher = $updateSession.CreateUpdateSearcher() Write-Host "Searching for pending updates..." -ForegroundColor Yellow $searchResult = $updateSearcher.Search("IsInstalled=0") Write-Host "Found $($searchResult.Updates.Count) pending update(s)`n" -ForegroundColor Green foreach ($update in $searchResult.Updates) { Write-Host ("=" * 80) -ForegroundColor DarkGray Write-Host "TITLE: $($update.Title)" -ForegroundColor Cyan Write-Host ("-" * 80) -ForegroundColor DarkGray # Size properties $minMB = [math]::Round($update.MinDownloadSize / 1MB, 2) $maxMB = [math]::Round($update.MaxDownloadSize / 1MB, 2) $ratio = if ($minMB -gt 0) { [math]::Round($maxMB / $minMB, 2) } else { "N/A" } Write-Host "`nSIZE ANALYSIS:" -ForegroundColor Yellow Write-Host " MinDownloadSize: $minMB MB" Write-Host " MaxDownloadSize: $maxMB MB" Write-Host " Ratio (Max/Min): $ratio" # Categories Write-Host "`nCATEGORIES:" -ForegroundColor Yellow foreach ($cat in $update.Categories) { Write-Host " - $($cat.Name) (Type: $($cat.Type))" } # Bundled updates Write-Host "`nBUNDLED UPDATES: $($update.BundledUpdates.Count)" -ForegroundColor Yellow if ($update.BundledUpdates.Count -gt 0) { $bundledTotalMin = 0 $bundledTotalMax = 0 foreach ($bundled in $update.BundledUpdates) { $bMinMB = [math]::Round($bundled.MinDownloadSize / 1MB, 2) $bMaxMB = [math]::Round($bundled.MaxDownloadSize / 1MB, 2) $bundledTotalMin += $bundled.MinDownloadSize $bundledTotalMax += $bundled.MaxDownloadSize Write-Host " [$bMinMB MB / $bMaxMB MB] $($bundled.Title)" } Write-Host " --- Bundled Totals ---" Write-Host " Sum of MinDownloadSize: $([math]::Round($bundledTotalMin / 1MB, 2)) MB" Write-Host " Sum of MaxDownloadSize: $([math]::Round($bundledTotalMax / 1MB, 2)) MB" } # Download contents (actual files) Write-Host "`nDOWNLOAD CONTENTS: $($update.DownloadContents.Count) file(s)" -ForegroundColor Yellow foreach ($content in $update.DownloadContents) { Write-Host " - URL: $($content.DownloadUrl)" } # Other properties Write-Host "`nOTHER PROPERTIES:" -ForegroundColor Yellow Write-Host " IsDownloaded: $($update.IsDownloaded)" Write-Host " IsMandatory: $($update.IsMandatory)" Write-Host " AutoSelectOnWebSites: $($update.AutoSelectOnWebSites)" Write-Host " RebootRequired: $($update.RebootRequired)" Write-Host " UpdateID: $($update.Identity.UpdateID)" Write-Host " RevisionNumber: $($update.Identity.RevisionNumber)" # KB Articles if ($update.KBArticleIDs.Count -gt 0) { Write-Host " KBs: $($update.KBArticleIDs -join ', ')" } Write-Host "" } } catch { Write-Host "ERROR: $_" -ForegroundColor Red } Write-Host "`n=== Diagnostic Complete ===" -ForegroundColor Cyan |