首页 > 解决方案 > 如何使用 PowerShell 获取所有已安装的 Windows 更新名称和 KB 编号?

问题描述

我需要使用 PowerShell 获取所有已安装的 Windows 更新。

结果应包含更新名称、KB 编号、CVE id 和严重性等级。我尝试了下一个脚本: Get-HotFix, wmic qfe list, Get-WmiObject -Class Win32_QuickFixEngineering. 但它只返回 KB 数字。我还尝试从下一个脚本结果过滤安装更新: Get-ChildItem -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages'. 但此脚本并非返回所有更新。

下一个脚本也不会返回所有已安装的 Windows 更新:

    $Searcher = $Session.CreateUpdateSearcher()
    $HistoryCount = $Searcher.GetTotalHistoryCount()
    $Updates = $Searcher.Search("IsPresent=1").Updates
    $Updates | ForEach-Object {$_}

我没有更多的想法,我将不胜感激。

标签: windowspowershellupdates

解决方案


查看 PowerShell 库中的PSWindowsUpdate模块。此模块中的Get-WUHistorycmdlet 可能包含您需要的一切。


推荐阅读