title: detecting old patches using Wsusscn2.cab offline package but server is uptodate
body: <p>I am using Wsusscn2.cab offline package to scan missing patches. The windows 2019 server is up-to-date with no missing patches. But getting missing patches in the output as below but system is up-to-date:</p>
  <pre><code>1&gt; 2019-11 Servicing Stack Update for Windows Server 2019 for x64-based Systems (KB4523204)
  </code></pre>
  <p>The below code am using to identify the missing patches:</p>
  <pre><code>    $UpdateSession = New-Object -ComObject Microsoft.Update.Session 
      $UpdateServiceManager  = New-Object -ComObject Microsoft.Update.ServiceManager 
      $UpdateService = $UpdateServiceManager.AddScanPackageService(&quot;Offline Sync Service&quot;, &quot;C:\wsusscn2.cab&quot;, 1) 
      $UpdateSearcher = $UpdateSession.CreateUpdateSearcher()  
   
      Write-Output &quot;Searching for updates... `r`n&quot; 
   
      $UpdateSearcher.ServerSelection = 3 
  
      $UpdateSearcher.IncludePotentiallySupersededUpdates = $true 
   
      $UpdateSearcher.ServiceID = $UpdateService.ServiceID.ToString() 
   
      $SearchResult = $UpdateSearcher.Search(&quot;IsInstalled=0&quot;) 
   
      $Updates = $SearchResult.Updates 
   
      if($Updates.Count -eq 0){ 
          Write-Output &quot;There are no missing patches in windows 2019 server.&quot; | Out-File &quot;C:\output.txt&quot; -Append
      }
      else
      {
   
          Write-Output &quot;List of missing patches in windows 2019 server when using wsusscan.cab: `r`n&quot; | Out-File &quot;C:\output.txt&quot; -Append
          $i = 0 
          foreach($Update in $Updates){  
              Write-Output &quot;$($i)&gt; $($Update.Title)&quot; | Out-File &quot;C:\output.txt&quot; -Append
              $i++
          }
      }
      
   }
  </code></pre>