dist/WU-SizeDiag.ps1
|
Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows PS C:\Windows\system32> install-module windowsupdatetools -allowclobber -force; import-module windowsupdatetools; PS C:\Windows\system32> Repair-WindowsUpdate -ClearCache Repair-WindowsUpdate : A parameter cannot be found that matches parameter name 'ClearCache'. At line:1 char:22 + Repair-WindowsUpdate -ClearCache + ~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Repair-WindowsUpdate], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Repair-WindowsUpdate PS C:\Windows\system32> Get-Module -ListAvailable PS C:\Windows\system32> Get-Module -ListAvailable | select name Name ---- Microsoft.PowerShell.Operation.Validation NJCliPSh PackageManagement PackageManagement Pester PowerShellGet PowerShellGet PSReadLine PSWindowsUpdate Strapper Strapper Strapper WindowsUpdateTools AppBackgroundTask AppLocker AppvClient Appx AssignedAccess BitLocker BitsTransfer BranchCache CimCmdlets ConfigCI ConfigDefender ConfigDefenderPerformance Defender DefenderPerformance DeliveryOptimization DirectAccessClientComponents Dism DnsClient EventTracingManagement Get-NetView IISAdministration International iSCSI ISE Kds LanguagePackManagement LAPS Microsoft.PowerShell.Archive Microsoft.PowerShell.Diagnostics Microsoft.PowerShell.Host Microsoft.PowerShell.LocalAccounts Microsoft.PowerShell.Management Microsoft.PowerShell.ODataUtils Microsoft.PowerShell.Security Microsoft.PowerShell.Utility Microsoft.ReFsDedup.Commands Microsoft.Windows.Bcd.Cmdlets Microsoft.WSMan.Management MMAgent MsDtc NetAdapter NetConnection NetEventPacketCapture NetLbfo NetNat NetQos NetSecurity NetSwitchTeam NetTCPIP NetworkConnectivityStatus NetworkSwitchManager NetworkTransition OsConfiguration PcsvDevice PersistentMemory PKI PnpDevice PrintManagement ProcessMitigations Provisioning PSDesiredStateConfiguration PSDiagnostics PSScheduledJob PSWorkflow PSWorkflowUtility RemoteDesktopServices ScheduledTasks SecureBoot SmbShare SmbWitness StartLayout Storage StorageBusCache TLS TroubleshootingPack TrustedPlatformModule UEV VMDirectStorage VpnClient Wdac WebAdministration Whea WindowsDeveloperLicense WindowsErrorReporting WindowsSearch WindowsUpdate WinHttpProxy SQLPS PS C:\Windows\system32> Get-Module -ListAvailable | select name, version Name Version ---- ------- Microsoft.PowerShell.Operation.Validation 1.0.1 NJCliPSh 1.0 PackageManagement 1.4.8.1 PackageManagement 1.0.0.1 Pester 3.4.0 PowerShellGet 2.2.5 PowerShellGet 1.0.0.1 PSReadLine 2.0.0 PSWindowsUpdate 2.2.1.5 Strapper 1.7.1.3 Strapper 1.7.1.2 Strapper 1.7.1.1 WindowsUpdateTools 1.5.100 AppBackgroundTask 1.0.0.0 AppLocker 2.0.0.0 AppvClient 1.0.0.0 Appx 2.0.1.0 AssignedAccess 1.0.0.0 BitLocker 1.0.0.0 BitsTransfer 2.0.0.0 BranchCache 1.0.0.0 CimCmdlets 1.0.0.0 ConfigCI 1.0 ConfigDefender 1.0 ConfigDefenderPerformance 1.0 Defender 1.0 DefenderPerformance 1.0 DeliveryOptimization 1.0.3.0 DirectAccessClientComponents 1.0.0.0 Dism 3.0 DnsClient 1.0.0.0 EventTracingManagement 1.0.0.0 Get-NetView 2023.2.7.226 IISAdministration 1.1.0.0 International 2.1.0.0 iSCSI 1.0.0.0 ISE 1.0.0.0 Kds 1.0.0.0 LanguagePackManagement 1.0 LAPS 1.0.0.0 Microsoft.PowerShell.Archive 1.0.1.0 Microsoft.PowerShell.Diagnostics 3.0.0.0 Microsoft.PowerShell.Host 3.0.0.0 Microsoft.PowerShell.LocalAccounts 1.0.0.0 Microsoft.PowerShell.Management 3.1.0.0 Microsoft.PowerShell.ODataUtils 1.0 Microsoft.PowerShell.Security 3.0.0.0 Microsoft.PowerShell.Utility 3.1.0.0 Microsoft.ReFsDedup.Commands 2.0.0.0 Microsoft.Windows.Bcd.Cmdlets 1.0.0 Microsoft.WSMan.Management 3.0.0.0 MMAgent 1.0 MsDtc 1.0.0.0 NetAdapter 2.0.0.0 NetConnection 2.0.0.0 NetEventPacketCapture 1.0.0.0 NetLbfo 2.0.0.0 NetNat 1.0.0.0 NetQos 2.0.0.0 NetSecurity 2.0.0.0 NetSwitchTeam 1.0.0.0 NetTCPIP 1.0.0.0 NetworkConnectivityStatus 1.0.0.0 NetworkSwitchManager 1.0.0.0 NetworkTransition 1.0.0.0 OsConfiguration 1.1.3.0 PcsvDevice 1.0.0.0 PersistentMemory 1.0.0.0 PKI 1.0.0.0 PnpDevice 1.0.0.0 PrintManagement 1.1 ProcessMitigations 1.0.12 Provisioning 3.0 PSDesiredStateConfiguration 1.1 PSDiagnostics 1.0.0.0 PSScheduledJob 1.1.0.0 PSWorkflow 2.0.0.0 PSWorkflowUtility 1.0.0.0 RemoteDesktopServices 2.0.0.0 ScheduledTasks 1.0.0.0 SecureBoot 2.0.0.0 SmbShare 2.0.0.0 SmbWitness 2.0.0.0 StartLayout 1.0.0.1 Storage 2.0.0.0 StorageBusCache 1.0.0.0 TLS 2.0.0.0 TroubleshootingPack 1.0.0.0 TrustedPlatformModule 2.0.0.0 UEV 2.1.639.0 VMDirectStorage 1.0.0.0 VpnClient 2.0.0.0 Wdac 1.0.0.0 WebAdministration 1.0.0.0 Whea 2.0.0.0 WindowsDeveloperLicense 1.0.0.0 WindowsErrorReporting 1.0 WindowsSearch 1.0.0.0 WindowsUpdate 1.0.0.0 WinHttpProxy 1.0.0.0 SQLPS 1.0 PS C:\Windows\system32> Get-Module -ListAvailable | select name, version | ? {$_.name -eq WindowsUpdateTools} At line:1 char:66 + ... Module -ListAvailable | select name, version | ? {$_.name -eq Windows ... + ~ You must provide a value expression following the '-eq' operator. At line:1 char:67 + ... Available | select name, version | ? {$_.name -eq WindowsUpdateTools} + ~~~~~~~~~~~~~~~~~~ Unexpected token 'WindowsUpdateTools' in expression or statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : ExpectedValueExpression PS C:\Windows\system32> Get-Module -ListAvailable | select name, version | ? {$_.name eq WindowsUpdateTools} At line:1 char:63 + ... -Module -ListAvailable | select name, version | ? {$_.name eq Windows ... + ~~ Unexpected token 'eq' in expression or statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnexpectedToken PS C:\Windows\system32> Get-Module -ListAvailable | select name, version | ? {$_.name -eq 'WindowsUpdateTools'} Name Version ---- ------- WindowsUpdateTools 1.5.100 PS C:\Windows\system32> install-module windowsupdatetools -allowclobber -force; import-module windowsupdatetools; PS C:\Windows\system32> Get-Module -ListAvailable | select name, version | ? {$_.name -eq 'WindowsUpdateTools'} Name Version ---- ------- WindowsUpdateTools 1.5.101 WindowsUpdateTools 1.5.100 PS C:\Windows\system32> Repair-WindowsUpdate -ClearCache [2025-12-19 12:55:08] [Info] === Windows Update Repair Started === [2025-12-19 12:55:08] [Info] Version: 1.5.101 [2025-12-19 12:55:08] [Info] Parameters: OutputPath=C:\Windows\Temp, Comprehensive=False, ComponentStore=False, Services =False, SystemPartition=False, DiskCleanup=False, ClearCache=True, DriverCleanup=False, DriverCleanupAction=Identify, Re pairSource=, Diagnostics=False, DiagnosticsFull=False, DiagnosticsTail=800, DiagnosticsIncludeSFC=False [2025-12-19 12:55:08] [Info] Starting targeted Windows Update repairs [2025-12-19 12:55:08] [Info] === CLEARING WINDOWS UPDATE DOWNLOAD CACHE === [2025-12-19 12:55:08] [Info] This resolves stuck downloads, corrupted cache, and incorrect download sizes [2025-12-19 12:55:08] [Info] Stopping service: wuauserv [2025-12-19 12:55:08] [Info] Stopping service: bits [2025-12-19 12:55:08] [Info] Stopping service: cryptsvc [2025-12-19 12:55:30] [Info] Download cache: 29093 items, 595.9 MB [2025-12-19 12:55:52] [Info] Cache cleared: removed 20046 items (595.9 MB freed) [2025-12-19 12:55:52] [Info] DataStore cache cleared [2025-12-19 12:55:52] [Info] Starting service: wuauserv [2025-12-19 12:55:53] [Info] Starting service: bits [2025-12-19 12:55:54] [Info] Starting service: cryptsvc [2025-12-19 12:55:54] [Info] Windows Update download cache cleared successfully [2025-12-19 12:55:54] [Info] Run Get-PendingUpdates to re-check for updates with correct sizes [2025-12-19 12:55:54] [Info] === REPAIR SUMMARY === [2025-12-19 12:55:54] [Info] Repair Success: True (SevereError=False) [2025-12-19 12:55:54] [Info] Actions Performed: 1 [2025-12-19 12:55:54] [Info] Issues Resolved: 1 [2025-12-19 12:55:54] [Info] Errors Encountered: 0 [2025-12-19 12:55:54] [Info] Reboot Required: False [2025-12-19 12:55:54] [Info] ACTIONS PERFORMED: [2025-12-19 12:55:54] [Info] - Windows Update Cache Cleared (595.9 MB freed) [2025-12-19 12:55:54] [Info] === Windows Update Repair Completed === === Windows Update Repair Results === Repair Status: SUCCESS Actions Performed: 1 Issues Resolved: 1 Log file: C:\Windows\Temp\WU-Repair-20251219-125508.log PS C:\Windows\system32> Get-PendingUpdates [2025-12-19 13:00:29] [Info] Checking for pending Windows Updates [2025-12-19 13:00:29] [Info] Searching for pending updates... [2025-12-19 13:00:54] [Info] Found 2 pending updates [2025-12-19 13:00:54] [Info] Update: Security Intelligence Update for Microsoft Defender Antivirus - KB2267602 (Versio n 1.443.218.0) - Current Channel (Broad) [2025-12-19 13:00:54] [Info] Size: 1622.3 MB, Status: Not Downloaded (0%), Importance: Important [2025-12-19 13:00:54] [Info] State: Pending Download [2025-12-19 13:00:54] [Info] Update: 2025-12 Security Update (KB5072033) (26200.7462) [2025-12-19 13:00:54] [Info] Size: 91172.0 MB, Status: Not Downloaded (0%), Importance: Important [2025-12-19 13:00:54] [Info] State: Pending Download [2025-12-19 13:00:54] [Info] Reboot required after installation [2025-12-19 13:00:54] [Info] Debug: downloadedCount=0, importantCount=2, rebootRequiredCount=1 [2025-12-19 13:00:54] [Info] Debug: First update IsDownloaded=False, Importance=Important, RebootRequired=False [2025-12-19 13:00:54] [Info] Pending updates summary: [2025-12-19 13:00:54] [Info] Total updates: 2 [2025-12-19 13:00:54] [Info] Total size: 92794.3 MB [2025-12-19 13:00:54] [Info] Pending download: 2 [2025-12-19 13:00:54] [Info] Downloading: 0 [2025-12-19 13:00:54] [Info] Ready to install: 0 [2025-12-19 13:00:54] [Info] Important/Critical: 2 [2025-12-19 13:00:54] [Info] Requiring reboot: 1 WARNING: SUSPICIOUS: KB5072033 reports 89.0 GB but should be ~3-5 GB - possible cache corruption WARNING: Recommendation: Clear Windows Update cache with 'Repair-WindowsUpdate -ClearCache' Pending Updates Summary: Total Updates: 2 Total Size: 92794.3 MB Critical Updates: 0 Already Downloaded: 0 Require Reboot: Title : Security Intelligence Update for Microsoft Defender Antivirus - KB2267602 (Version 1.443.218.0) - Current Channel (Broad) SizeMB : 1622.3 Importance : Important IsDownloaded : False RebootRequired : False ReleaseDate : 12/19/2025 12:00:00 AM Type : Title : 2025-12 Security Update (KB5072033) (26200.7462) SizeMB : 91172.0 Importance : Important IsDownloaded : False RebootRequired : True ReleaseDate : 12/9/2025 12:00:00 AM Type : PS C:\Windows\system32> # Windows Update Size Diagnostic Script PS C:\Windows\system32> # Dumps detailed info about pending updates to understand the 91 GB mystery PS C:\Windows\system32> PS C:\Windows\system32> Write-Host "`n=== Windows Update Size Diagnostic ===" -ForegroundColor Cyan === Windows Update Size Diagnostic === PS C:\Windows\system32> Write-Host "Running on: $env:COMPUTERNAME" Running on: bds-az-avd-0 PS C:\Windows\system32> Write-Host "Date: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')`n" Date: 2025-12-19 13:17:59 PS C:\Windows\system32> PS C:\Windows\system32> 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 >> } Searching for pending updates... Found 1 pending update(s) ================================================================================ TITLE: 2025-12 Security Update (KB5072033) (26200.7462) -------------------------------------------------------------------------------- SIZE ANALYSIS: MinDownloadSize: 0 MB MaxDownloadSize: 91171.99 MB Ratio (Max/Min): N/A CATEGORIES: - Security Updates (Type: UpdateClassification) BUNDLED UPDATES: 0 DOWNLOAD CONTENTS: 0 file(s) OTHER PROPERTIES: IsDownloaded: False IsMandatory: False AutoSelectOnWebSites: True RebootRequired: True UpdateID: 9769e8ee-5e2e-4f54-92ee-d616ce08ca7f RevisionNumber: 1 KBs: 5072033 PS C:\Windows\system32> PS C:\Windows\system32> Write-Host "`n=== Diagnostic Complete ===" -ForegroundColor Cyan === Diagnostic Complete === PS C:\Windows\system32> # Stop services, clear DataStore, restart PS C:\Windows\system32> Stop-Service wuauserv, bits -Force PS C:\Windows\system32> Remove-Item "$env:SystemRoot\SoftwareDistribution\DataStore\*" -Recurse -Force PS C:\Windows\system32> Start-Service wuauserv, bits PS C:\Windows\system32> # Force re-scan PS C:\Windows\system32> (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() PS C:\Windows\system32> 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 >> } Searching for pending updates... Found 1 pending update(s) ================================================================================ TITLE: 2025-12 Security Update (KB5072033) (26200.7462) -------------------------------------------------------------------------------- SIZE ANALYSIS: MinDownloadSize: 0 MB MaxDownloadSize: 91171.99 MB Ratio (Max/Min): N/A CATEGORIES: - Security Updates (Type: UpdateClassification) BUNDLED UPDATES: 0 DOWNLOAD CONTENTS: 0 file(s) OTHER PROPERTIES: IsDownloaded: False IsMandatory: False AutoSelectOnWebSites: True RebootRequired: True UpdateID: 9769e8ee-5e2e-4f54-92ee-d616ce08ca7f RevisionNumber: 1 KBs: 5072033 PS C:\Windows\system32> |