-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-packages.ps1
27 lines (23 loc) · 1 KB
/
install-packages.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
# Define the directory
$packageDir = "\packages"
# Get all the package files
$packageFiles = Get-ChildItem -Path $packageDir -Filter "*.txt"
# Display the package files and ask the user to select which ones to install or choose to install all
Write-Host "Please select the packages to install (or enter 'all' to install all):"
for ($i=0; $i -lt $packageFiles.Count; $i++) {
Write-Host "$i. $($packageFiles[$i].Name)"
}
$userInput = Read-Host "Enter the numbers of the packages to install (separated by commas), or 'all'"
if ($userInput -eq 'all') {
# Install all packages
$selectedPackages = $packageFiles
} else {
# Convert the selected indices to an array and get the corresponding package files
$selectedIndices = $userInput.Split(',') | ForEach-Object { [int]$_ }
$selectedPackages = $selectedIndices | ForEach-Object { $packageFiles[$_] }
}
# Loop through the selected package files
foreach ($package in $selectedPackages) {
# Install the package
choco install $package.FullName -y
}