如何在 powershell windows 7 中使用 Microsoft.Update.Session()?
我想从Windows导出更新历史记录(已安装的KB)列表。 对于Windows 10,我发现了正在打击的代码:
$Session = New-Object -ComObject Microsoft.Update.Session
$Searcher = $Session.CreateUpdateSearcher()
$Searcher.QueryHistory(0, $Searcher.GetTotalHistoryCount()) | Export-Csv -Encoding UTF8 -Path D:\$env:computername+KB.csv -NoTypeInformation
但是,由于某些代码错误,我无法在Windows 7下使用它。
有人知道如何修复在Windows 7下运行的代码吗? 还是还有其他方法可以获取已安装的KB列表?
I want to export the update history(installed KB) list from Windows.
To Windows 10, I found the code under blow:
$Session = New-Object -ComObject Microsoft.Update.Session
$Searcher = $Session.CreateUpdateSearcher()
$Searcher.QueryHistory(0, $Searcher.GetTotalHistoryCount()) | Export-Csv -Encoding UTF8 -Path D:\$env:computername+KB.csv -NoTypeInformation
However, I can't use it under Windows 7, because of some code error.
Does anyone know how to repair the code to run under Windows 7 ?
or have any other way to get the installed KB list ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过 Google 快速搜索,DISM 也适用于 Window 7。它可以以列表格式输出。
如果您以管理员身份打开 PowerShell 窗口,则可以运行:
我不确定 DISM 是否默认随 Windows 7 一起提供。您可能需要下载和/或启用它。
From a quick Google search DISM is available for Window 7 as well. It can output in a list format.
If you open a PowerShell windows as Administrator, you can run:
I'm not sure if DISM comes with Windows 7 by default. You may need to download and/or enable it.