Reputation: 3
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? 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}
Upvotes: 0
Views: 590
Reputation: 22831
You can get this information with $patch.Date
within the foreach loop
Upvotes: 1