powershell - 使用 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++
}
}
}
解决方案
推荐阅读
- angular - 单击垫子切换按钮后如何停止垫子菜单关闭?
- database - 如何清除 Flutter 桌面应用程序数据,如 Flutter 移动应用程序
- javascript - React js:要在新选项卡中打印组件时加载字体
- rust - 将(迭代器)值传递给闭包(预期类型参数`I`,找到结构`std::slice::Iter`)有什么问题?
- javascript - 无法将文本复制到剪贴板但 innerHTML 读取内容
- normal-distribution - 如何使用 RosinRammlerDistribution 中的参数来调整粒子注入的配置文件
- python - 从数据框中的列中替换部分文本
- php - PHP一种在array_sum之后找到密钥的方法
- tensorflow - ImageDataGenerator flow_from_dataframe 多输出回归和分类语法问题
- math - 我想知道 math.sin 算法是如何在内部工作的?