-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListUpdates.ps1
More file actions
61 lines (50 loc) · 1.63 KB
/
ListUpdates.ps1
File metadata and controls
61 lines (50 loc) · 1.63 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
56
57
58
59
60
61
#
# Description: List Windows Update from computers in array and export to file.
# We used it for troubleshooting a strange problem which lead us to
# believe it could be a common windows update for the affected computers.
#
# Usage: 1) Enter hostnames in $hosts array
# 2) Change wanted timeline date in the Where-Object { } clause
# 3) Run script
#
# Note: - Requires local administrator access on remote computer (i.e. domain admin)
# - Threads aren't implemented so it currently queries the computers one by one.
#
# Author: Kim Eirik Kvassheim
# Website: https://github.com/kek91
#
$hosts = @(
"pc-01", "pc-02", "pc-03",
"pc-04", "pc-05", "pc-06"
)
Write-Host "Collecting Windows Updates logs`n"
foreach($i in $hosts) {
$output = "Host: " + $i + "`t"
$status = "Offline"
try {
if(Test-Connection -computername $i -quiet) {
$status = "Online"
}
}
catch {
$status = "Error"
}
$output += "Status: " + $status + "`t"
if($status -eq "Online") {
try {
# Select Caption, HotfixID, Description, InstalledOn, ++
Get-Hotfix -computername $i |
Select HotfixID, InstalledOn |
Where-Object {
$_.InstalledOn -gt "02/01/2017 00:00:00" -AND $_.InstalledOn -lt "03/28/2017 00:00:00"
} |
Sort-Object InstalledOn > $i".txt"
$output += "Log: "+$i+".txt"
}
catch {
$output += "Log: Error"
}
}
Write-Host $output
}
Write-Host "`nComplete"