我厌倦了编写一个 Powershell 脚本,它将返回可用的 Windows 更新计数,就像 Windows 返回计数一样。我遇到的问题是我无法让我的计数与 Window's Update 返回的计数相匹配。
例如我的脚本可能会返回:
关键计数:0
重要计数:1
可选计数:30
但 Windows 更新会说有:
关键计数:1
重要计数:1
可选计数:29
有谁知道 Windows 使用什么标准来显示Windows 更新中的计数?
这是我的代码示例:
# ----- Get All Assigned updates --------
$UpdateSession = New-Object -ComObject "Microsoft.Update.Session"
$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
$SearchResult = $UpdateSearcher.Search('IsInstalled=0')
# ----- Matrix Results for type of updates that are needed --------
$critical = $SearchResult.updates | where { $_.MsrcSeverity -eq "Critical" }
$important = $SearchResult.updates | where { $_.MsrcSeverity -eq "Important" }
$optional = $SearchResult.updates | where { ($_.MsrcSeverity -ne "Critical") -and ($_.MsrcSeverity -ne "Important") }