-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-InstalledUpdatesFromEventLog.ps1
More file actions
55 lines (45 loc) · 2.04 KB
/
Copy pathGet-InstalledUpdatesFromEventLog.ps1
File metadata and controls
55 lines (45 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<#
.SYNOPSIS
Liest die Installationshistorie von Windows-Updates aus dem
Systemprotokoll.
.DESCRIPTION
Filtert das Systemprotokoll auf Eintraege des Anbieters
Microsoft-Windows-WindowsUpdateClient und gibt Zeitpunkt, Update-Titel
und Ergebnis aus.
Anders als Get-HotFix erfasst das auch Updates, die nicht als
QFE-Eintrag hinterlegt sind - etwa Definitionsupdates und
Funktionsupdates.
.NOTES
Reicht nur so weit zurueck, wie das Systemprotokoll aufbewahrt wird.
Nach einem Leeren des Protokolls ist die Historie weg.
#>
function Get-InstalledUpdatesFromEventLog {
$filterXml = @'
<QueryList>
<Query Id="0" Path="System">
<Select Path="System">
*[System[Provider[@Name='Microsoft-Windows-WindowsUpdateClient']]]
</Select>
</Query>
</QueryList>
'@
Get-WinEvent -FilterXPath $filterXml -LogName System |
ForEach-Object {
[pscustomobject]@{
EventId = $_.Id
UpdateGuid = $_.Properties[1].Value
InstalledOn = $_.TimeCreated
UpdateTitle = $_.Properties[0].Value
}
}
}
# Execute the function
# Get-InstalledUpdatesFromEventLog | Sort-Object -Property InstalledOn,EventID -Descending | Out-GridView
# Successful Installs = 19
Get-InstalledUpdatesFromEventLog | Where-Object EventID -eq 19 | Sort-Object -Property InstalledOn -Descending | Out-GridView -Title "Successful Installs = 19"
# Not Successful Installs = 20
Get-InstalledUpdatesFromEventLog | Where-Object EventID -eq 20 | Sort-Object -Property InstalledOn -Descending | Out-GridView -Title "Not Successful Installs = 20"
# Feature Updates / Cumulative Updates = 43
Get-InstalledUpdatesFromEventLog | Where-Object EventID -eq 43 | Sort-Object -Property InstalledOn -Descending | Out-GridView -Title "Feature Updates / Cumulative Updates = 43"
# Download has started Installs = 44
Get-InstalledUpdatesFromEventLog | Where-Object EventID -eq 44 | Sort-Object -Property InstalledOn -Descending | Out-GridView -Title "Download has started Installs = 44"