简体   繁体   English

脚本Powershell列出已安装的更新

[英]Script Powershell to list installed updates

I'm new here, I am looking for a script for me to list the Windows Updates and then put them on Excel, I have a lot of code that works set apart the display of dates, can you help? 我是新来的人,我正在寻找一个脚本供我列出Windows Update,然后将其放在Excel中,我有很多可以分开显示日期的代码,您可以帮忙吗? Here is the code: 这是代码:

$System=Get-WmiObject -Class Win32_OperatingSystem -Computer .

$system=$System.CSName 

$Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()

$updateSearcher = new-object -com "Microsoft.Update.Searcher"
$totalupdates = $updateSearcher.GetTotalHistoryCount()
$patchList=$updateSearcher.QueryHistory(0,$totalupdates)

write-host "Nombre total de patches installés sur le poste [$system] :" $patchList.Count
write-host "Préparation du classeur Excel...."

$Sheet = $Excel.Worksheets.Item(1)
$Sheet.Name = "Patches installés"
$Sheet.Cells.Item(1,1) = "Titre"
$Sheet.Cells.Item(1,2) = "Description"
$Sheet.Cells.Item(1,3) = "Date"

$Sheet.activate()

$Sheet.application.activewindow.splitrow = 1
$Sheet.application.activewindow.freezepanes = $true

$intRow = 2

$WorkBook = $Sheet.UsedRange

$WorkBook.Interior.ColorIndex = 11
$WorkBook.Font.ColorIndex = 19
$WorkBook.Font.Bold = $True

Foreach($patch in $patchList){

$HotfixID=$patch.Title
$HotfixID=$HotfixID.Split('(')
$HotfixID=$HotfixID[1]
$HotfixID=$HotfixID.Trim(')')

$Sheet.Cells.Item($intRow, 1) = $HotfixID
$Sheet.Cells.Item($intRow, 2) = $patch.Title
$Sheet.Cells.Item($intRow, 3) = $patch.Installeddate

$intRow = $intRow + 1}

您可以在foreach循环中使用$patch.Date获取此信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Powershell 在控制面板的“程序和功能”中获取“查看已安装的更新”列表? - How to get list of "view installed updates" in "programs and features" in control panel using Powershell? 以编程方式获取 Windows 中所有已安装更新的列表 - Programmatically get a list of all installed updates in Windows 使用VBScript获取已安装更新的列表作为Windows Update的一部分 - Get list of installed updates as part of Windows Updates using VBScript 是否有一种无需搜索注册表即可获取已安装.NET更新列表的方法? - Is there a way to get a list of installed .NET updates without searching the registry? API / WMI查询系统上安装的修补程序和更新的完整列表? - API/WMI Query for complete list of hotfixes and updates installed on a system? 如何获取已安装的更新和修补程序列表? - How do I get a list of installed updates and hotfixes? 是否可以使用node.js获取已安装的Windows Update列表? - Is it possible to get a list of installed Windows Updates using node.js? 用于在许多 PC 上批量更新 Windows 更新的 Powershell 脚本 - Powershell script for bulk updating Windows Updates on many pc's vbscript Windows更新不在已安装的更新中 - vbscript windows updates not in installed updates 如何使用 Powershell 卸载软件更新(程序和功能\已安装的更新) - How can I uninstall Software Update (Programs and Features\Installed Updates) with Powershell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM