Skip to content

Commit

Permalink
[windows] Update Get-WindowsUpdateStates function (#11397)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamil-mubarakshin authored Jan 20, 2025
1 parent af0df29 commit ee530b0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions images/windows/scripts/helpers/InstallHelpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,15 @@ function Get-WindowsUpdateStates {
19 {
$state = "Installed"
$title = $event.Properties[0].Value
$completedUpdates[$title] = ""
$completedUpdates[$title] = $state
break
}
20 {
$state = "Failed"
$title = $event.Properties[1].Value
$completedUpdates[$title] = ""
if (-not $completedUpdates.ContainsKey($title)) {
$completedUpdates[$title] = $state
}
break
}
43 {
Expand All @@ -454,8 +456,13 @@ function Get-WindowsUpdateStates {
}
}

# Skip update started event if it was already completed
if ( $state -eq "Running" -and $completedUpdates.ContainsKey($title) ) {
# Skip Running update event if it was already completed
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
}

Expand Down

0 comments on commit ee530b0

Please sign in to comment.