【问题标题】:powershell windows missing updatespowershell windows缺少更新
【发布时间】:2014-06-11 15:36:06
【问题描述】:

尝试创建 powershell 脚本以列出丢失或待处理的 Windows 更新。目的是针对计算机/服务器列表运行脚本,以查看是否缺少任何更新或修补程序,并生成您需要查看的服务器列表。

有没有人对此有解决方案,一直在寻找没有任何成功的脚本来执行此操作。

【问题讨论】:

  • 您有想要应用的更新的基本列表吗?这些机器是由 SCCM 还是其他一些补丁管理系统管理的?
  • 不是真的,我正在寻找的列表是 Windows 更新列表,我想看看 f.e.对于 server1 已发布但尚未安装在服务器上的更新列表。按重要性分组会很好,所以 f.e.你可能会得到 - 有 6 个更新的待处理 4 个关键 2 个可选等。我想将此添加到我的脚本中,该脚本每晚运行并从我管理的选定服务器的事件日志中报告正常运行时间、重启时间和选定事件。

标签: windows powershell updates


【解决方案1】:

列出缺失更新的 Powershell 脚本

脚本:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted

#List all missing updates
Write-Output "Creating Microsoft.Update.Session COM object" 
$session1 = New-Object -ComObject Microsoft.Update.Session -ErrorAction silentlycontinue

Write-Output "Creating Update searcher" 
$searcher = $session1.CreateUpdateSearcher()

Write-Output "Searching for missing updates..." 
$result = $searcher.Search("IsInstalled=0")

#Updates are waiting to be installed 
$updates = $result.Updates;

Write-Output "Found $($updates.Count) updates!" 

$updates | Format-Table Title, AutoSelectOnWebSites, IsDownloaded, IsHiden, IsInstalled, IsMandatory, IsPresent, AutoSelection, AutoDownload -AutoSize

pause

示例输出:

Creating Microsoft.Update.Session COM object
Creating Update searcher
Searching for missing updates...
Found 4 updates!

Title                                                                                                               AutoSelectOnWebSites IsDownloaded IsHiden IsInstalled IsMandatory IsPrese
                                                                                                                                                                                           nt
-----                                                                                                               -------------------- ------------ ------- ----------- ----------- -------
Intel - Other hardware - Intel(R) Xeon(R) E3 - 1200/1500 v5/6th Gen Intel(R) Core(TM) PCIe Controller (x16) - 1901                 False        False               False       False   False
Intel - Other hardware - Intel(R) Xeon(R) E3 - 1200/1500 v5/6th Gen Intel(R) Core(TM) Gaussian Mixture Model - 1911                False        False               False       False   False
Microsoft Silverlight (KB4481252)                                                                                                  False        False               False       False   False
SQL Server 2019 RTM Cumulative Update (CU) 4 KB4548597                                                                             False        False               False       False   False


Press Enter to continue...:

【讨论】:

    【解决方案2】:

    有一个来自 TechNet 的示例脚本可以执行您正在寻找的核心逻辑:

    Get-WindowsUpdates.ps1

    还有老的VBScript-based WUA_SearchDownloadInstall.vbs。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-09
    • 1970-01-01
    • 2012-07-10
    相关资源
    最近更新 更多