我目前正在编写一个脚本,如果发布新的 Windows 更新,它会向我发送一封电子邮件。
获取 WindowsUpdate
输出:
ComputerName Status KB Size Title ------------ ------ -- ---- -----
MD-I-T-092 ------- 2MB Intel - System - 4/12/2017 12:00:00 AM - 14.28.47.630
MD-I-T-092 ------- 24KB Dell Inc. - Monitor - 1/30/2018 12:00:00 AM -
MD-I-T-092 ------- 46KB Intel - System - 9/19/2017 12:00:00 AM - 11.7.0.1000
MD-I-T-092 ------- 9MB Lenovo Ltd. - Firmware - 1.0.0.50
MD-I-T-092 ------- 346KB Lenovo Ltd. - Firmware - 1.0.0.41
目前,仅提供“驱动程序”更新。当 Windows 更新可用时,我想检索更新的“KB”号和“标题”。
获取 WindowsUpdate |选择对象-属性KB(或大小/标题等)
这个方法不起作用。
我猜这是因为该属性不可用。
获取 WindowsUpdate |选择-属性*
由于此方法( https://social.technet.microsoft.com/Forums/en-US/b7e3b522-04b5-4cd5-a228-837deff9d7b8/windows-update-powershell-module-display-category-with-getwindowsupdate-aka-getwulist-cmdlet?forum=ITCG )对我不起作用,您对如何过滤输出还有其他想法吗? 在 StackO 上我没有找到一篇对我有帮助的文章,但如果你知道,请告诉我:)
最佳答案
我假设您正在使用 PsWindowsUpdate模块。 看来该模块编写得不好,并且默认情况下不会发出很好的可用对象。
你可以这样获取它们:
(Get-WindowsUpdate).GetEnumerator() |哪里对象 KB -ne '' |选择对象KB、大小、标题
。
它给出这样的输出(假设找到匹配的更新):
KB Size Title
-- ---- -----
KB5011644 697MB SQL Server 2019 RTM Cumulative Update (CU) 16 KB5011644
KB5014356 457MB Security Update for SQL Server 2019 RTM GDR (KB5014356)
KB5013887 67MB 2022-06 Cumulative Update for .NET Framework 3.5 and 4.8 for Windows 10 Version 21H2 for x64 (KB5013887)
KB2267602 789MB Security Intelligence Update for Microsoft Defender Antivirus - KB2267602 (Version 1.367.1700.0)
关于windows - 选择对象,不同的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72657554/