Skip to content

Commit

Permalink
Merge pull request #10 from PluginsOCSInventory-NG/add_hotfixes
Browse files Browse the repository at this point in the history
add hotfixes data
  • Loading branch information
charleneauger authored Jun 11, 2021
2 parents 707bc04 + cdf11bb commit a9b22b8
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion agent/winupdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ $Searcher = $Session.CreateUpdateSearcher()
$historyCount = $Searcher.GetTotalHistoryCount()

$UpdateHistory = $Searcher.QueryHistory(0, $historyCount) | Select *

$updates = @()
foreach ($Update in $UpdateHistory) {
[regex]::match($Update.Title,'(KB[0-9]{6,7})').value | Where-Object {$_ -ne ""} | foreach {
$op = Get-Operation($Update.Operation)
$stat = Get-Status($Update.ResultCode)
if (-Not ($_ -in $updates)) {
$updates += $_
}

$xml += "<WINUPDATESTATE>`n"
$xml += "<KB>" + $_ + "</KB>`n"
$xml += "<TITLE>" + $Update.Title + "</TITLE>`n"
Expand All @@ -40,5 +44,20 @@ foreach ($Update in $UpdateHistory) {
}
}


$hotfixes = Get-HotFix | ForEach-Object {
if ($updates -NotContains $_.HotFixID) {
$xml += "<WINUPDATESTATE>`n"
$xml += "<KB>" + $_.HotFixID + "</KB>`n"
$xml += "<TITLE>" + "HotFix" + "</TITLE>`n"
$xml += "<DATE>" + $_.InstalledOn + "</DATE>`n"
$xml += "<OPERATION>" + "Installation" + "</OPERATION>`n"
$xml += "<STATUS>" + "Succeeded" + "</STATUS>`n"
$xml += "<SUPPORTLINK> </SUPPORTLINK>`n"
$xml += "<DESCRIPTION>" + $_.Description + "</DESCRIPTION>`n"
$xml += "</WINUPDATESTATE>`n"
}
}

[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::WriteLine($xml)

0 comments on commit a9b22b8

Please sign in to comment.