0

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}
1
  • Do you not just require $patch.Date? Commented Mar 6, 2014 at 13:30

1 Answer 1

1

You can get this information with $patch.Date within the foreach loop

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.