Update InstallApps.ps1
This commit is contained in:
parent
03404a4948
commit
224c65f4b0
|
@ -1,6 +1,9 @@
|
|||
# Get the current directory where the script is located
|
||||
$currentDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
|
||||
# Define the path for logging installed applications
|
||||
$logFilePath = "/winget/installedApps.txt"
|
||||
|
||||
# Function to display a menu and get user input
|
||||
function Show-Menu {
|
||||
param (
|
||||
|
@ -58,6 +61,16 @@ function Select-MultipleOptions {
|
|||
return $selectedOptions | ForEach-Object { $options[$_] }
|
||||
}
|
||||
|
||||
# Function to log installed applications
|
||||
function Log-InstalledApp {
|
||||
param (
|
||||
[string]$appName # The name of the installed application
|
||||
)
|
||||
|
||||
# Append the application name to the log file
|
||||
Add-Content -Path $logFilePath -Value $appName
|
||||
}
|
||||
|
||||
# Main script logic starts here
|
||||
$mainMenuChoice = Show-Menu "Do you want to:" @("Update all apps", "Install apps")
|
||||
|
||||
|
@ -78,7 +91,11 @@ switch ($mainMenuChoice) {
|
|||
# Sub-option 2a: Fresh install of ALL apps
|
||||
Write-Host "Performing fresh install of all apps..."
|
||||
# Execute all scripts in the groups folder
|
||||
Get-ChildItem -Path "$currentDir\install\groups\*.ps1" | ForEach-Object { & $_.FullName }
|
||||
Get-ChildItem -Path "$currentDir\install\groups\*.ps1" | ForEach-Object {
|
||||
& $_.FullName
|
||||
# Log the installed app (assuming script file names are app names)
|
||||
Log-InstalledApp -appName $_.Name
|
||||
}
|
||||
}
|
||||
2 {
|
||||
# Sub-option 2b: Select package groups for installation
|
||||
|
@ -91,6 +108,8 @@ switch ($mainMenuChoice) {
|
|||
foreach ($group in $selectedGroups) {
|
||||
Write-Host "Installing group: $group"
|
||||
& "$currentDir\install\groups\$group"
|
||||
# Log the installed group (assuming group script names are group names)
|
||||
Log-InstalledApp -appName $group
|
||||
}
|
||||
}
|
||||
3 {
|
||||
|
@ -104,6 +123,8 @@ switch ($mainMenuChoice) {
|
|||
foreach ($package in $selectedPackages) {
|
||||
Write-Host "Installing package: $package"
|
||||
& $package
|
||||
# Log the installed package
|
||||
Log-InstalledApp -appName $package
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user