-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwinget.ps1
More file actions
79 lines (72 loc) · 2.1 KB
/
winget.ps1
File metadata and controls
79 lines (72 loc) · 2.1 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Script to install applications using WinGet
# Author: Your Name
# Date: YYYY-MM-DD
# Define applications in an array of hashtables for easy maintenance
$applications = @(
@{
Name = "Adobe Reader"
PackageName = "Adobe.Acrobat.Reader.64-bit"
},
@{
Name = "Greenshot"
PackageName = "Greenshot.Greenshot"
},
@{
Name = "Power BI Desktop"
PackageName = "Microsoft.PowerBI"
},
@{
Name = "VS Code"
PackageName = "vscode"
},
@{
Name = "Dell Command Update"
PackageName = "Dell.CommandUpdate"
},
@{
Name = "Windows Apps"
PackageName = "9N1F85V9T8BN"
}
)
function Show-Menu {
# Sort the applications alphabetically before displaying
$sortedApplications = $applications | Sort-Object -Property Name
Write-Host "Application Installation Menu"
Write-Host "========================================="
$i = 1
foreach ($app in $sortedApplications) {
Write-Host "$i. $($app.Name)"
$i++
}
Write-Host "0. Exit"
Write-Host "========================================="
# Return sorted applications for use elsewhere
return $sortedApplications
}
function Install-Application {
param (
[int]$index,
[array]$sortedApplications
)
if ($index -ge 1 -and $index -le $sortedApplications.Count) {
$app = $sortedApplications[$index - 1]
Write-Host "Installing $($app.Name)..."
$command = "winget install $($app.PackageName) --scope machine --accept-package-agreements --accept-source-agreements"
Invoke-Expression $command
} else {
Write-Host "Invalid selection. Please try again."
}
}
# Main loop
do {
$sortedApplications = Show-Menu
$choice = Read-Host "Enter your choice (number):"
if ($choice -eq 0) {
Write-Host "Exiting script. Goodbye!"
break
} elseif ($choice -match "^\d+$") {
Install-Application -index $choice -sortedApplications $sortedApplications
} else {
Write-Host "Invalid input. Please enter a number."
}
} while ($true)