-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_Rsat_1809.ps1
367 lines (332 loc) · 17.8 KB
/
install_Rsat_1809.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
<#
.SYNOPSIS
This is a Powershell script to help install Windows RSAT Tools for Windows 1809 and later
.DESCRIPTION
This is a Powershell script to help install Windows RSAT Tools for Windows 1809 and later
.EXAMPLE
Gui Mode
./install_Rsat_1809.exe
Silent Mode install all features
./install_Rsat_1809.exe -silent -all
Silent Mode remove all features
./install_Rsat_1809.exe -silent -all [-action 'remove']
Silent Mode install specific features
./install-Rsat_1809.exe -silent [-ADDS -GPO -Bitlocker -WSUS -DHCP -DNS]
.NOTES
Run in gui mode by default.
Throw silent switch to run it with no interaction
.LINK
http://kevinpelgrims.wordpress.com
#>
[CmdletBinding()]
Param (
$action="install",
[switch]$silent=$false,
[switch]$all=$true,
[switch]$ADDS=$false
)
Function GUI {
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$form = New-Object System.Windows.Forms.Form
$form.Text = 'RSAT Tools to install'
$form.Size = New-Object System.Drawing.Size(300,450)
$form.StartPosition = 'CenterScreen'
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Point(75,370)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = 'OK'
$OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $OKButton
$form.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Point(150,370)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = 'Cancel'
$CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $CancelButton
$form.Controls.Add($CancelButton)
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'Please choose RSAT Tools from the list below:'
$form.Controls.Add($label)
$listBox = New-Object System.Windows.Forms.Listbox
$listBox.Location = New-Object System.Drawing.Point(10,40)
$listBox.Size = New-Object System.Drawing.Size(260,320)
$listBox.AutoSize = $true
$listBox.SelectionMode = 'MultiExtended'
[void] $listBox.Items.Add('Active Directory DS-LDS')
[void] $listBox.Items.Add('Bitlocker Recovery')
[void] $listBox.Items.Add('Certificate Services')
[void] $listBox.Items.Add('DHCP')
[void] $listBox.Items.Add('DNS')
[void] $listBox.Items.Add("Failover Cluster Management")
[void] $listBox.Items.Add('File Services')
[void] $listBox.Items.Add('Group Policy Management')
[void] $listBox.Items.Add('IPAM Client')
[void] $listBox.Items.Add('LLDP')
[void] $listBox.Items.Add('Network Controller')
[void] $listBox.Items.Add("Network Load Balancing")
[void] $listBox.Items.Add('Remote Access Management')
[void] $listBox.Items.Add('Remote Desktop Services')
[void] $listBox.Items.Add('Server Manager')
[void] $listBox.Items.Add('Shielded VM')
[void] $listBox.Items.Add('Storage Replica')
[void] $listBox.Items.Add('Storage Migration Service Management')
[void] $listBox.Items.Add('System Insights Management')
[void] $listBox.Items.Add('Volume Activation')
[void] $listBox.Items.Add('WSUS')
$listBox.Height = 70
$form.Controls.Add($listBox)
$form.Topmost = $true
$selectAllCheckbox = New-Object System.Windows.Forms.CheckBox
$selectAllCheckbox.Location = New-Object System.Drawing.Point(10,320)
$selectAllCheckbox.Text = "Select all Items"
$selectAllCheckbox.Add_Click({
if ($selectAllCheckbox.Checked -eq $true ) {
for ($i = 0; $i -lt $listBox.Items.Count; $i++) {
$listBox.SetSelected($i, $true)
}
}
elseif ( $selectAllCheckBox.Checked -eq $false) {
$listBox.ClearSelected()
}})
$form.Controls.Add($selectAllCheckbox)
$uninstallAction = New-Object System.Windows.Forms.CheckBox
$uninstallAction.Location = New-Object System.Drawing.Point(10,341)
$uninstallAction.Size = New-Object System.Drawing.Size(200,20)
$uninstallAction.Text = "Uninstall Selected Tools"
$form.Controls.Add($uninstallAction)
$result = $form.ShowDialog()
if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
$selectionsize = $listBox.SelectedItems.count
$selections = $listBox.SelectedItems
if ( $uninstallAction.Checked -eq $true ) {
Uninstall($listBox.SelectedItems)
}
else {
Install($listBox.SelectedItems)
}
}
}
Function RegistryEdit {
#Turn on online resources for RSAT Tools
$RegistryPath = "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Servicing"
$RegistryName1 = "LocalSourcePath"
$RegistryName2 = "RepairContentServerSource"
$RegistryValue2 = "2"
$RegistryValue1 = ""
if (!(Test-Path -Path $RegistryPath)) {
New-Item -Path $RegistryPath
New-ItemProperty -Path $RegistryPath -PropertyType ExpandString -Name $RegistryName1 -Value $RegistryValue1 -Force | Out-Null
New-ItemProperty -Path $RegistryPath -PropertyType DWord -Name $RegistryName2 -Value $RegistryValue2 -Force | Out-Null
}
else {
New-ItemProperty -Path $RegistryPath -PropertyType DWord -Name $RegistryName2 -Value $RegistryValue2 -Force | Out-Null
New-ItemProperty -Path $RegistryPath -PropertyType ExpandString -Name $RegistryName1 -Value $RegistryValue1 -Force | Out-Null
}
}
Function Install($selections)
{
If ( ($selections.Count -eq 21) -or ($silent -and $all )) {
Add-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.BitLocker.Recovery.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.CertificateServices.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.DHCP.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.Dns.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.FailoverCluster.Management.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.FileServices.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.IPAM.Client.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.LLDP.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.NetworkController.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.NetworkLoadBalancing.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.RemoteAccess.Management.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.RemoteDesktop.Services.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.ServerManager.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.Shielded.VM.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.StorageReplica.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.VolumeActivation.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.WSUS.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.StorageMigrationService.Management.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.SystemInsights.Management.Tools~~~~0.0.1.0
}
else {
For ($i=0; $i -lt $selections.Count; $i++) {
if (( $selections[$i] -eq 'Active Directory DS-LDS' ) -or ($silent -and $ADDS )) {
Add-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0
}
elseif (( $selections[$i] -eq 'Bitlocker Recovery') -or ($silent -and $Bitlocker )) {
Add-WindowsCapability -Online -Name Rsat.BitLocker.Recovery.Tools~~~~0.0.1.0
}
elseif (( $selections[$i] -eq 'Certificate Services') -or ($silent -and $CertificateServices )) {
Add-WindowsCapability -Online -Name Rsat.CertificateServices.Tools~~~~0.0.1.0
}
elseif (( $selections[$i] -eq 'DHCP' ) -or ($silent -and $DHCP )) {
Add-WindowsCapability -Online -Name Rsat.DHCP.Tools~~~~0.0.1.0
}
elseif (( $selections[$i] -eq 'DNS' ) -or ($silent -and $DNS )) {
Add-WindowsCapability -Online -Name Rsat.Dns.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Failover Cluster Management' ) {
Add-WindowsCapability -Online -Name Rsat.FailoverCluster.Management.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'File Services' ) {
Add-WindowsCapability -Online -Name Rsat.FileServices.Tools~~~~0.0.1.0
}
elseif (( $selections[$i] -eq 'Group Policy Management' ) -or ($silent -and $GPO )){
Add-WindowsCapability -Online -Name Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'IPAM Client' ) {
Add-WindowsCapability -Online -Name Rsat.IPAM.Client.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'LLDP' ) {
Add-WindowsCapability -Online -Name Rsat.LLDP.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Network Controller' ) {
Add-WindowsCapability -Online -Name Rsat.NetworkController.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Network Load Balancing' ) {
Add-WindowsCapability -Online -Name Rsat.NetworkLoadBalancing.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Remote Access Management' ) {
Add-WindowsCapability -Online -Name Rsat.RemoteAccess.Management.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Remote Desktop Services' ) {
Add-WindowsCapability -Online -Name Rsat.RemoteDesktop.Services.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Server Manager' ) {
Add-WindowsCapability -Online -Name Rsat.ServerManager.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Shielded VM' ) {
Add-WindowsCapability -Online -Name Rsat.Shielded.VM.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Storage Replica' ) {
Add-WindowsCapability -Online -Name Rsat.StorageReplica.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Storage Migration Service Management' ) {
Add-WindowsCapability -Online -Name Rsat.StorageMigrationService.Management.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'System Insights Management' ) {
Add-WindowsCapability -Online -Name Rsat.SystemInsights.Management.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Volume Activation' ) {
Add-WindowsCapability -Online -Name Rsat.VolumeActivation.Tools~~~~0.0.1.0
}
elseif (( $selections[$i] -eq 'WSUS' ) -or ($silent -and $WSUS )) {
Add-WindowsCapability -Online -Name Rsat.WSUS.Tools~~~~0.0.1.0
}
}
}
}
Function Uninstall($selections)
{
If (( $selections.Count -eq 21 ) -or ($silent -and $all )) {
Remove-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.BitLocker.Recovery.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.CertificateServices.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.DHCP.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.Dns.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.FailoverCluster.Management.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.FileServices.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.IPAM.Client.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.LLDP.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.NetworkController.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.NetworkLoadBalancing.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.RemoteAccess.Management.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.RemoteDesktop.Services.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.ServerManager.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.Shielded.VM.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.StorageReplica.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.VolumeActivation.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.WSUS.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.StorageMigrationService.Management.Tools~~~~0.0.1.0
Remove-WindowsCapability -Online -Name Rsat.SystemInsights.Management.Tools~~~~0.0.1.0
}
else {
For ($i=0; $i -lt $selections.Count; $i++) {
if (( $selections[$i] -eq 'Active Directory DS-LDS' ) -or ($silent -and $ADDS )) {
Remove-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0
}
elseif (( $selections[$i] -eq 'Bitlocker Recovery') -or ($silent -and $Bitlocker )) {
Remove-WindowsCapability -Online -Name Rsat.BitLocker.Recovery.Tools~~~~0.0.1.0
}
elseif (( $selections[$i] -eq 'Certificate Services') -or ($silent -and $CertificatesServices )) {
Remove-WindowsCapability -Online -Name Rsat.CertificateServices.Tools~~~~0.0.1.0
}
elseif (( $selections[$i] -eq 'DHCP' ) -or ($silent -and $DHCP )) {
Remove-WindowsCapability -Online -Name Rsat.DHCP.Tools~~~~0.0.1.0
}
elseif (( $selections[$i] -eq 'DNS' ) -or ($silent -and $DNS )) {
Remove-WindowsCapability -Online -Name Rsat.Dns.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Failover Cluster Management' ) {
Remove-WindowsCapability -Online -Name Rsat.FailoverCluster.Management.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'File Services' ) {
Add-WindowsCapability -Online -Name Rsat.FileServices.Tools~~~~0.0.1.0
}
elseif (( $selections[$i] -eq 'Group Policy Management' ) -or ($silent -and $GPO )) {
Remove-WindowsCapability -Online -Name Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'IPAM Client' ) {
Remove-WindowsCapability -Online -Name Rsat.IPAM.Client.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'LLDP' ) {
Remove-WindowsCapability -Online -Name Rsat.LLDP.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Network Controller' ) {
Remove-WindowsCapability -Online -Name Rsat.NetworkController.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Network Load Balancing' ) {
Remove-WindowsCapability -Online -Name Rsat.NetworkLoadBalancing.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Remote Access Management' ) {
Remove-WindowsCapability -Online -Name Rsat.RemoteAccess.Management.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Remote Desktop Services' ) {
Remove-WindowsCapability -Online -Name Rsat.RemoteDesktop.Services.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Server Manager' ) {
Remove-WindowsCapability -Online -Name Rsat.ServerManager.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Shielded VM' ) {
Remove-WindowsCapability -Online -Name Rsat.Shielded.VM.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Storage Replica' ) {
Remove-WindowsCapability -Online -Name Rsat.StorageReplica.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Storage Migration Service Management' ) {
Remove-WindowsCapability -Online -Name Rsat.StorageMigrationService.Management.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'System Insights Management' ) {
Remove-WindowsCapability -Online -Name Rsat.SystemInsights.Management.Tools~~~~0.0.1.0
}
elseif ( $selections[$i] -eq 'Volume Activation' ) {
Remove-WindowsCapability -Online -Name Rsat.VolumeActivation.Tools~~~~0.0.1.0 -InformationAction Inquire
}
elseif (( $selections[$i] -eq 'WSUS' ) -or ($silent -and $WSUS )) {
Remove-WindowsCapability -Online -Name Rsat.WSUS.Tools~~~~0.0.1.0
}
}
}
}
if ($silent) {
RegistryEdit
if($action -eq "remove") {
Uninstall
}
elseif ($action -eq "install") {
Install
}
elseif ( $action -eq "" ) {
Write-Host 'get-help install_Rsat_1809.ps1 -examples'
}
}
else {
RegistryEdit
GUI
}