mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-13 21:36:46 +00:00
[Windows] Add test to validate windows updates installation (#4489)
* Add test to validate windows updates installation * Add function Get-WindowsUpdatesHistory
This commit is contained in:
committed by
GitHub
parent
1b583e05e5
commit
df27520b1f
@@ -489,3 +489,47 @@ function Get-AndroidPackagesByVersion {
|
||||
$packagesByVersion = $packagesByName | Where-Object { ($_.Split($Delimiter)[$Index] -as $Type) -ge $MinimumVersion }
|
||||
return $packagesByVersion | Sort-Object { $_.Split($Delimiter)[$Index] -as $Type} -Unique
|
||||
}
|
||||
|
||||
function Get-WindowsUpdatesHistory {
|
||||
$allEvents = @{}
|
||||
# 19 - Installation Successful: Windows successfully installed the following update
|
||||
# 20 - Installation Failure: Windows failed to install the following update with error
|
||||
# 43 - Installation Started: Windows has started installing the following update
|
||||
$filter = @{
|
||||
LogName = "System"
|
||||
Id = 19, 20, 43
|
||||
ProviderName = "Microsoft-Windows-WindowsUpdateClient"
|
||||
}
|
||||
$events = Get-WinEvent -FilterHashtable $filter -ErrorAction SilentlyContinue | Sort-Object Id
|
||||
|
||||
foreach ( $event in $events ) {
|
||||
switch ( $event.Id ) {
|
||||
19 {
|
||||
$status = "Successful"
|
||||
$title = $event.Properties[0].Value
|
||||
$allEvents[$title] = ""
|
||||
break
|
||||
}
|
||||
20 {
|
||||
$status = "Failure"
|
||||
$title = $event.Properties[1].Value
|
||||
$allEvents[$title] = ""
|
||||
break
|
||||
}
|
||||
43 {
|
||||
$status = "InProgress"
|
||||
$title = $event.Properties[0].Value
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if ( $status -eq "InProgress" -and $allEvents.ContainsKey($title) ) {
|
||||
continue
|
||||
}
|
||||
|
||||
[PSCustomObject]@{
|
||||
Status = $status
|
||||
Title = $title
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user