-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWSUS Cleanup.ps1
140 lines (122 loc) · 5.16 KB
/
WSUS Cleanup.ps1
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
set-executionpolicy RemoteSigned
$WsusServer = ([system.net.dns]::GetHostByName('localhost')).hostname
$UseSSL = $false
$PortNumber = 8530
$TrialRun = 0
# 1 = Yes
# 0 = No#
# Connect to the WSUS 3.0 interface.
[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null
$WsusServerAdminProxy = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer($WsusServer,$UseSSL,$PortNumber);
# Searching in just the title of the update
# Itanium/IA64
$itanium = $WsusServerAdminProxy.GetUpdates() | ?{-not $_.IsDeclined -and $_.Title -match “ia64|itanium”}
$IA64_counted = $itanium.count
If ($itanium.count -lt 1)
{
$IA64_counted = 0
}
If ($TrialRun -eq 0 -and $itanium.count -gt 0)
{
$itanium | %{$_.Decline()}
}
"$IA64_counted Itanium updates wurden abgelehnt"
# MS Office 64-Bit
$Office64 = $WsusServerAdminProxy.GetUpdates() | ?{-not $_.IsDeclined -and $_.Title -match “Excel|Lync|Office|Outlook|Powerpoint|Visio|word” -and $_.Title -match "64-bit"}
$Office64_count = $Office64.count
If ($Office64.count -lt 1)
{
$Office64_count = 0
}
If ($TrialRun -eq 0 -and $Office64.count -gt 0)
{
$Office64 | %{$_.Decline()}
}
"$Office64_count MS Office 64-Bit wurden abgelehnt"
# Searching in just the title of the update
# Language Pack
$LanguagePack = $WsusServerAdminProxy.GetUpdates() | ?{-not $_.IsDeclined -and $_.Title -match “Language Interface Pack”}
$LanguagePack_counted = $LanguagePack.count
If ($LanguagePack.count -lt 1)
{
$LanguagePack_counted = 0
}
If ($TrialRun -eq 0 -and $LanguagePack.count -gt 0)
{
$LanguagePack | %{$_.Decline()}
}
$LanguagePackVer2 = $WsusServerAdminProxy.GetUpdates() | ?{-not $_.IsDeclined -and $_.Title -match “LanguageInterfacePack - Windows 10”}
$LanguagePack_counted = $LanguagePackVer2.count + $LanguagePack_counted
If ($LanguagePack.count -lt 1)
{
$LanguagePack_counted = 0
}
If ($TrialRun -eq 0 -and $LanguagePackVer2.count -gt 0)
{
$LanguagePackVer2 | %{$_.Decline()}
}
"$LanguagePack_counted Language Interface Packs wurden abgelehnt"
# Searching in just the title of the update
# Language Pack - Windows 10 -
$LanguagePackW10 = $WsusServerAdminProxy.GetUpdates() | ?{-not $_.IsDeclined -and $_.Title -match “Language Pack - Windows 10 -”}
$LanguagePackW10_counted = $LanguagePackW10.count
If ($LanguagePackW10.count -lt 1)
{
$LanguagePackW10_counted = 0
}
If ($TrialRun -eq 0 -and $LanguagePackW10.count -gt 0)
{
$LanguagePackW10 | %{$_.Decline()}
}
"$LanguagePackW10_counted Language Pack - Windows 10 wurden abgelehnt"
# Searching in just the title of the update
# LanguagePack - Windows 10 Insider Preview
$LPW10InsiderPreview = $WsusServerAdminProxy.GetUpdates() | ?{-not $_.IsDeclined -and $_.Title -match “LanguagePack - Windows 10 Insider Preview”}
$LPW10InsiderPreview_counted = $LPW10InsiderPreview.count
If ($LPW10InsiderPreview.count -lt 1)
{
$LPW10InsiderPreview_counted = 0
}
If ($TrialRun -eq 0 -and $LPW10InsiderPreview.count -gt 0)
{
$LPW10InsiderPreview | %{$_.Decline()}
}
"$LPW10InsiderPreview_counted LanguagePack - Windows 10 Insider Preview wurden abgelehnt"
# Searching in just the title of the update
# LanguageInterfacePack - Windows 10 Insider Preview
$LiPW10InsiderPreview = $WsusServerAdminProxy.GetUpdates() | ?{-not $_.IsDeclined -and $_.Title -match “LanguageInterfacePack - Windows 10 Insider Preview”}
$LiPW10InsiderPreview_counted = $LiPW10InsiderPreview.count
If ($LiPW10InsiderPreview.count -lt 1)
{
$LiPW10InsiderPreview_counted = 0
}
If ($TrialRun -eq 0 -and $LiPW10InsiderPreview.count -gt 0)
{
$LiPW10InsiderPreview | %{$_.Decline()}
}
"$LiPW10InsiderPreview_counted LanguageInterfacePack - Windows 10 Insider Preview wurden abgelehnt"
# Searching in just the title of the update
# LanguageInterfacePack - Windows 10 Insider Preview
$LiPW10InsiderPreview = $WsusServerAdminProxy.GetUpdates() | ?{-not $_.IsDeclined -and $_.Title -match “LanguageInterfacePack - Windows 10 Insider Preview”}
$LiPW10InsiderPreview_counted = $LiPW10InsiderPreview.count
If ($LiPW10InsiderPreview.count -lt 1)
{
$LiPW10InsiderPreview_counted = 0
}
If ($TrialRun -eq 0 -and $LiPW10InsiderPreview.count -gt 0)
{
$LiPW10InsiderPreview | %{$_.Decline()}
}
# Searching in just the title of the update
# “ARM64
$arm64 = $WsusServerAdminProxy.GetUpdates() | ?{-not $_.IsDeclined -and $_.Title -match “ARM64”}
$ARM64_counted = $arm64.count
If ($ARM64.count -lt 1)
{
$ARM64_counted = 0
}
If ($TrialRun -eq 0 -and $arm64.count -gt 0)
{
$ARM64 | %{$_.Decline()}
}
"$ARM64_counted ARM64 Updates wurden abgelehnt"