[windows] Update Get-WindowsUpdateStates function (#11397)

This commit is contained in:
Shamil Mubarakshin
2025-01-20 11:12:30 +01:00
committed by GitHub
parent af0df29967
commit ee530b00e3

View File

@@ -438,13 +438,15 @@ function Get-WindowsUpdateStates {
19 { 19 {
$state = "Installed" $state = "Installed"
$title = $event.Properties[0].Value $title = $event.Properties[0].Value
$completedUpdates[$title] = "" $completedUpdates[$title] = $state
break break
} }
20 { 20 {
$state = "Failed" $state = "Failed"
$title = $event.Properties[1].Value $title = $event.Properties[1].Value
$completedUpdates[$title] = "" if (-not $completedUpdates.ContainsKey($title)) {
$completedUpdates[$title] = $state
}
break break
} }
43 { 43 {
@@ -454,8 +456,13 @@ function Get-WindowsUpdateStates {
} }
} }
# Skip update started event if it was already completed # Skip Running update event if it was already completed
if ( $state -eq "Running" -and $completedUpdates.ContainsKey($title) ) { if ( ($state -eq "Running") -and $completedUpdates.ContainsKey($title) ) {
continue
}
# Skip Failed update event if it was already successfully installed
if ( ($state -eq "Failed") -and $completedUpdates[$title] -eq "Installed" ) {
continue continue
} }