[英]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.