-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWinget-Installscript.ps1
323 lines (287 loc) · 23.6 KB
/
Winget-Installscript.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
#Unterdrücke Fortschrittsinformationen, erstelle Titel für das Programm und passe die Fenstergröße an.
$ProgressPreference = 'SilentlyContinue'
$host.ui.RawUI.WindowTitle = "Windows Package Manager - Setup"
[Console]::WindowWidth=103;
[Console]::Windowheight=43;
[Console]::setBufferSize(103,43) #width,height
#Logobereich (ASCII-Style)
$Display = {
Write-Host " __ __.__ __ _________ __
/ \ / \__| ____ ____ _____/ |_ / _____/ _____/ |_ __ ________
\ \/\/ / |/ \ / ___\_/ __ \ __\ ______ \_____ \_/ __ \ __\ | \____ \
\ /| | | \/ /_/ > ___/| | /_____/ / \ ___/| | | | / |_> >
\__/\ / |__|___| /\___ / \___ >__| /_______ /\___ >__| |____/| __/
\/ \//_____/ \/ \/ \/ |__| " -ForegroundColor Cyan
Write-Host " @sd-itlab.de v5.5.0" -ForegroundColor Red
}
#Abschlussvariable, wenn der Installationsprozess abgeschlossen ist.
$End = {
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ╠═══════════════════════════════════════════════════════════════════════════════════════════════╣" -ForegroundColor Yellow
Write-Host " ║ " -ForegroundColor Yellow -NoNewline
Write-Host "Der Installationsprozess war Erfolgreich!" -ForegroundColor Green -NoNewline
Write-Host " ║" -ForegroundColor Yellow
Write-Host " ╚═══════════════════════════════════════════════════════════════════════════════════════════════╝" -ForegroundColor Yellow
Start-Sleep 2
}
#Winget Prüfung, ob Winget und dessen Abhängigkeiten installiert sind.
function InstallWinget {
#Installationsprüfung ob benötigte Abhängigkeiten vorhanden ist.
Clear-Host
Invoke-Command -ScriptBlock $Display
Write-Host " ══╦═══════════════════════════════════════════════════════════════════════════════════════════════╦══" -ForegroundColor Yellow
Write-Host " ╠═══════════════════════════════════════" -ForegroundColor Yellow -NoNewline
Write-Host " Winget Script " -ForegroundColor White -NoNewline
Write-Host "═══════════════════════════════════════╣" -ForegroundColor Yellow
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ║" -ForegroundColor Yellow -NoNewLine
Write-Host " Überprüfe auf fehlenden Abhängigkeiten... " -ForegroundColor Red -NoNewLine
Write-Host "║" -ForegroundColor Yellow
#Abhängigkeitsprüfung
#Prüft, ob Microsoft UI Xaml 2.8.6 installiert ist, wenn nicht, dann installieren dies
$Xaml = Get-AppxPackage -Name 'Microsoft.UI.Xaml.2.8'
$XamlMinimumVersion = [version]"8.2310.30001.0"
if ($Xaml.Version -lt $XamlMinimumVersion) {
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ║" -ForegroundColor Yellow -NoNewLine
Write-Host " Installiere Abhängigkeit: Mircosoft UI Xaml 2.8... " -ForegroundColor Red -NoNewLine
Write-Host "║" -ForegroundColor Yellow
New-Item C:\Windows\Temp\Winget -ItemType directory | Out-Null
Invoke-WebRequest -Uri 'https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.8.6' -OutFile C:\Windows\Temp\Winget\microsoft.ui.xaml.2.8.6.zip
Expand-Archive C:\Windows\Temp\Winget\microsoft.ui.xaml.2.8.6.zip -DestinationPath C:\Windows\Temp\Winget\microsoft.ui.xaml.2.8.6 | Out-Null
Add-AppxPackage -Path 'C:\Windows\Temp\Winget\microsoft.ui.xaml.2.8.6\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.8.appx' | Out-Null
Remove-Item 'C:\Windows\Temp\Winget' -Recurse | Out-Null
}
else {
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ║" -ForegroundColor Yellow -NoNewLine
Write-Host " Abhängigkeit: Mircosoft UI Xaml 2.8 ist bereits installiert... " -ForegroundColor Green -NoNewLine
Write-Host "║" -ForegroundColor Yellow
}
#Abhängigkeitsprüfung
#Prüfen, ob Microsoft VCLibs X64 140.00 installiert ist, wenn nicht, dann installieren dies
$VCLibs = Get-AppxPackage -Name 'Microsoft.VCLibs.140.00.UWPDesktop'
$VCLibsminimumVersion = [version]"14.0.33519.0"
if ($VCLibs -and $VCLibs.Version -lt $VCLibsminimumVersion) {
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ║" -ForegroundColor Yellow -NoNewLine
Write-Host " Installiere Abhängigkeit: VCLibs.x64.14... " -ForegroundColor Red -NoNewLine
Write-Host "║" -ForegroundColor Yellow
Add-AppxPackage -Path 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx' | Out-Null
}
else {
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ║" -ForegroundColor Yellow -NoNewLine
Write-Host " Abhängigkeit: VCLibs.x64.14 ist bereits installiert... " -ForegroundColor Green -NoNewLine
Write-Host "║" -ForegroundColor Yellow
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ╚═══════════════════════════════════════════════════════════════════════════════════════════════╝" -ForegroundColor Yellow
}
#Installationsprüfung des Hauptbestandteils von Winget
Clear-Host
Invoke-Command -ScriptBlock $Display
Write-Host " ══╦═══════════════════════════════════════════════════════════════════════════════════════════════╦══" -ForegroundColor Yellow
Write-Host " ╠════════════════════════════════════" -ForegroundColor Yellow -NoNewline
Write-Host " Winget Installation " -ForegroundColor White -NoNewline
Write-Host "════════════════════════════════════╣" -ForegroundColor Yellow
Write-Host " ║ ║" -ForegroundColor Yellow
#Prüfen, ob Microsoft DesktopAppInstaller (Winget) installiert ist, wenn nicht, dann installieren dies
$Winget = Get-AppxPackage -name 'Microsoft.DesktopAppInstaller'
if ($Winget.Version -ge [version]"1.23.0.0") {
Write-Host " ║" -ForegroundColor Yellow -NoNewLine
Write-Host " Winget ist bereits Installiert... " -ForegroundColor Green -NoNewLine
Write-Host "║" -ForegroundColor Yellow
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ╚═══════════════════════════════════════════════════════════════════════════════════════════════╝" -ForegroundColor Yellow
}
else {
$releases_url = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
Write-Host " ║" -ForegroundColor Yellow -NoNewLine
Write-Host " Installiere aktuellste Winget-Cli Version... " -ForegroundColor Red -NoNewLine
Write-Host "║" -ForegroundColor Yellow
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$releases = Invoke-RestMethod -uri $releases_url
$latestRelease = $releases.assets | Where-Object { $_.browser_download_url.EndsWith('msixbundle') } | Select-Object -First 1
Add-AppxPackage -Path $latestRelease.browser_download_url
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ╚═══════════════════════════════════════════════════════════════════════════════════════════════╝" -ForegroundColor Yellow
}
}
#Ausgewähle Programme Prüfen, ob installiert, wenn nicht Installiere diese.
function InstallApps {
param (
[Parameter(Mandatory = $true)]
[string[]]
$apps
)
Clear-Host
Invoke-Command -ScriptBlock $Display
Write-Host " ══╦═══════════════════════════════════════════════════════════════════════════════════════════════╦══" -ForegroundColor Yellow
Write-Host " ╠═══════════════════════════════════" -ForegroundColor Yellow -NoNewline
Write-Host " Software Installation " -ForegroundColor White -NoNewline
Write-Host "═══════════════════════════════════╣" -ForegroundColor Yellow
Write-Host " ║ ║" -ForegroundColor Yellow
#Programm Installation Abschnitt
foreach ($app in $apps) {
#Überprüfe für jede ausgewählte App, ob diese bereits Installiert ist, wenn nicht, Installiere diese
$listApp = winget list --exact --accept-source-agreements -q $app
if (![String]::Join("", $listApp).Contains($app)) {
$atext = "Erfolgreich! "
$adesiredWidth = 70
Start-Sleep 1
#Berechne die Länge des $app.name und des $atext, um den verbleibenden Platz für den App-Namen zu bestimmen
$aremainingAppNameWidth = $adesiredWidth - $atext.Length - 5
#Erstelle den wiederholten Text von $app.name und fülle mit Leerzeichen auf, um den gewünschten Zeichenplatz zu erreichen
$apaddedAppName = ($app + " " * $aremainingAppNameWidth).Substring(0, $aremainingAppNameWidth)
Write-Host " ║ " -ForegroundColor Yellow -NoNewline
Write-Host " Installiere Software: $apaddedAppName"-ForegroundColor Red -NoNewline
winget install --id $app -e -h --accept-package-agreements | Out-Null
Write-Host "| $atext" -ForegroundColor Green -NoNewline
Write-Host " ║" -ForegroundColor Yellow
}
else {
$btext = "ist bereits installiert "
$bdesiredWidth = 72
#Berechne die Länge des $app.name und des $btext, um den verbleibenden Platz für den App-Namen zu bestimmen
$bremainingAppNameWidth = $bdesiredWidth - $btext.Length - 5
#Erstelle den wiederholten Text von $app.name und fülle mit Leerzeichen auf, um den gewünschten Zeichenplatz zu erreichen
$bpaddedAppName = ($app + " " * $bremainingAppNameWidth).Substring(0, $bremainingAppNameWidth)
Write-Host " ║ " -ForegroundColor Yellow -NoNewline
Write-Host " Installiere Software: $bpaddedAppName"-ForegroundColor Red -NoNewline
Write-Host "| $btext" -ForegroundColor Green -NoNewline
Write-Host "║" -ForegroundColor Yellow
Start-Sleep 1
}
}
Invoke-Command -ScriptBlock $End
Start-Sleep 2
menu
}
#Menüanzeige, um verfügbare Auswahlmöglichkeiten anzuzeigen.
function menu {
Clear-Host
Invoke-Command -ScriptBlock $Display
Write-Host " ══════════════╦═══════════════════════════════════════════════════════════════════════╦══════════════"-ForegroundColor Yellow
Write-Host " ╠══════════════════════" -ForegroundColor Yellow -NoNewline
Write-Host " Windows Package Manager " -ForegroundColor Magenta -NoNewline
Write-Host "══════════════════════╣" -ForegroundColor Yellow
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ║" -ForegroundColor Yellow -NoNewLine
Write-Host " 1: Installation der Software ohne Java " -ForegroundColor Cyan -NoNewLine
Write-Host "║" -ForegroundColor Yellow
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ║" -ForegroundColor Yellow -NoNewLine
Write-Host " 2: Installation der Software ohne Java und Thunderbird " -ForegroundColor Cyan -NoNewLine
Write-Host "║" -ForegroundColor Yellow
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ║" -ForegroundColor Yellow -NoNewLine
Write-Host " 3: Installation der Software mit Java " -ForegroundColor Cyan -NoNewLine
Write-Host "║" -ForegroundColor Yellow
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ║" -ForegroundColor Yellow -NoNewLine
Write-Host " 4: Installation der Software mit Java aber ohne Thunderbird " -ForegroundColor Cyan -NoNewLine
Write-Host "║" -ForegroundColor Yellow
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ╠══════════════════════════" -ForegroundColor Yellow -NoNewline
Write-Host " Weitere Programme " -ForegroundColor Magenta -NoNewline
Write-Host "══════════════════════════╣" -ForegroundColor Yellow
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ║"-ForegroundColor Yellow -NoNewline
Write-Host " DOCUMENTS TOOLS " -ForegroundColor Magenta -NoNewline
Write-Host "║" -ForegroundColor Yellow
Write-Host " ║"-ForegroundColor Yellow -NoNewline
Write-Host " 5: LibreOffice 9: Notepad++ 13: Oracle Java 8 " -ForegroundColor Cyan -NoNewline
Write-Host "║" -ForegroundColor Yellow
Write-Host " ║"-ForegroundColor Yellow -NoNewline
Write-Host " 6: OpenOffice 10: 7Zip 14: Adobe Reader DC " -ForegroundColor Cyan -NoNewline
Write-Host "║" -ForegroundColor Yellow
Write-Host " ║"-ForegroundColor Yellow -NoNewline
Write-Host " 7: OnlyOffice 11: Everything 15: VLC-Media Player " -ForegroundColor Cyan -NoNewline
Write-Host "║" -ForegroundColor Yellow
Write-Host " ║"-ForegroundColor Yellow -NoNewline
Write-Host " 8: PDF24 Creator 12: Thunderbird 16: Malwarebytes " -ForegroundColor Cyan -NoNewline
Write-Host "║" -ForegroundColor Yellow
Write-Host " ║ ║"
Write-Host " ║"-ForegroundColor Yellow -NoNewline
Write-Host " REMOTE BROWSER " -ForegroundColor Magenta -NoNewline
Write-Host "║" -ForegroundColor Yellow
Write-Host " ║"-ForegroundColor Yellow -NoNewline
Write-Host " 17: Teamviewer 20: Google Chrome 23: Opera " -ForegroundColor Cyan -NoNewline
Write-Host "║" -ForegroundColor Yellow
Write-Host " ║"-ForegroundColor Yellow -NoNewline
Write-Host " 18: Anydesk 21: Mozilla Firefox 24: Opera GX " -ForegroundColor Cyan -NoNewline
Write-Host "║" -ForegroundColor Yellow
Write-Host " ║"-ForegroundColor Yellow -NoNewline
Write-Host " 19: Rustdesk 22: Brave Browser " -ForegroundColor Cyan -NoNewline
Write-Host "║" -ForegroundColor Yellow
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ╠═══════════════════════════════════════════════════════════════════════╣" -ForegroundColor Yellow
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ║" -ForegroundColor Yellow -NoNewLine
Write-Host " 0: Beenden 30: Readme " -ForegroundColor Magenta -NoNewLine
Write-Host "║" -ForegroundColor Yellow
Write-Host " ║ ║" -ForegroundColor Yellow
Write-Host " ╚═══════════════════════════════════════════════════════════════════════╝" -ForegroundColor Yellow
Write-Host
$actions = Read-Host -Prompt ' Was möchten Sie tun? [Beispiel: 1,2,3,4]'
if ($actions -eq 0) {
exit
}
if ($actions -eq 30) {
Clear-Host
Start-Process "https://sd-itlab.de/winget/"
menu
}
#App-Auswahl-Paket, (Menünummer 1-24), Gewünschte nummern werden zur Installations-auswahl hinzugefügt
$selectedApps = $actions -split ',' | ForEach-Object { $_.Trim() }
if ($selectedApps -notcontains '0' -and $selectedApps.Count -ge 1) {
Install-List -appNumbers $selectedApps
Start-Sleep 1
menu
}
else {
Write-Host "Ungültige Auswahl. Bitte wählen Sie erneut." -ForegroundColor Red
Start-Sleep 1
menu
}
}
#App-Auswahl-Paket, definiere, welche Programme welcher Nummer zugewiesen werden.
function Install-List {
param (
[string[]]$appNumbers
)
$selectedApps = @()
foreach ($selectedApp in $appNumbers) {
switch ($selectedApp) {
'1' { $selectedApps += "Mozilla.Firefox", "Google.Chrome", "Mozilla.Thunderbird", "VideoLAN.VLC", "Adobe.Acrobat.Reader.64-bit" }
'2' { $selectedApps += "Mozilla.Firefox", "Google.Chrome", "VideoLAN.VLC", "Adobe.Acrobat.Reader.64-bit" }
'3' { $selectedApps += "Mozilla.Firefox", "Google.Chrome", "Mozilla.Thunderbird", "VideoLAN.VLC", "Adobe.Acrobat.Reader.64-bit", "Oracle.JavaRuntimeEnvironment" }
'4' { $selectedApps += "Mozilla.Firefox", "Google.Chrome", "VideoLAN.VLC", "Adobe.Acrobat.Reader.64-bit", "Oracle.JavaRuntimeEnvironment" }
'5' { $selectedApps += "TheDocumentFoundation.LibreOffice" }
'6' { $selectedApps += "Apache.OpenOffice" }
'7' { $selectedApps += "ONLYOFFICE.DesktopEditors" }
'8' { $selectedApps += "geeksoftwareGmbH.PDF24Creator" }
'9' { $selectedApps += "Notepad++.Notepad++" }
'10' { $selectedApps += "7zip.7zip" }
'11' { $selectedApps += "voidtools.Everything" }
'12' { $selectedApps += "Mozilla.Thunderbird" }
'13' { $selectedApps += "Oracle.JavaRuntimeEnvironment" }
'14' { $selectedApps += "Adobe.Acrobat.Reader.64-bit" }
'15' { $selectedApps += "VideoLAN.VLC" }
'16' { $selectedApps += "Malwarebytes.Malwarebytes" }
'17' { $selectedApps += "TeamViewer.TeamViewer" }
'18' { $selectedApps += "AnyDeskSoftwareGmbH.AnyDesk" }
'19' { $selectedApps += "RustDesk.RustDesk" }
'20' { $selectedApps += "Google.Chrome" }
'21' { $selectedApps += "Mozilla.Firefox" }
'22' { $selectedApps += "Brave.Brave" }
'23' { $selectedApps += "Opera.Opera" }
'24' { $selectedApps += "Opera.OperaGX" }
}
}
InstallWinget
InstallApps -apps $selectedApps
Start-Sleep 2
menu
}
menu