首页 > 解决方案 > 使用 Wsusscn2.cab 离线包检测旧补丁,但服务器是最新的

问题描述

我正在使用 Wsusscn2.cab 离线包来扫描丢失的补丁。Windows 2019 服务器是最新的,没有缺少补丁。但是在输出中缺少补丁,如下所示,但系统是最新的:

1> 2019-11 Servicing Stack Update for Windows Server 2019 for x64-based Systems (KB4523204)

以下代码用于识别缺失的补丁:

    $UpdateSession = New-Object -ComObject Microsoft.Update.Session 
    $UpdateServiceManager  = New-Object -ComObject Microsoft.Update.ServiceManager 
    $UpdateService = $UpdateServiceManager.AddScanPackageService("Offline Sync Service", "C:\wsusscn2.cab", 1) 
    $UpdateSearcher = $UpdateSession.CreateUpdateSearcher()  
 
    Write-Output "Searching for updates... `r`n" 
 
    $UpdateSearcher.ServerSelection = 3 

    $UpdateSearcher.IncludePotentiallySupersededUpdates = $true 
 
    $UpdateSearcher.ServiceID = $UpdateService.ServiceID.ToString() 
 
    $SearchResult = $UpdateSearcher.Search("IsInstalled=0") 
 
    $Updates = $SearchResult.Updates 
 
    if($Updates.Count -eq 0){ 
        Write-Output "There are no missing patches in windows 2019 server." | Out-File "C:\output.txt" -Append
    }
    else
    {
 
        Write-Output "List of missing patches in windows 2019 server when using wsusscan.cab: `r`n" | Out-File "C:\output.txt" -Append
        $i = 0 
        foreach($Update in $Updates){  
            Write-Output "$($i)> $($Update.Title)" | Out-File "C:\output.txt" -Append
            $i++
        }
    }
    
 }

标签: powershellscriptingdevopspatchwindows-update

解决方案


推荐阅读