Update install-basic-apps.ps1

This commit is contained in:
Markus Fleschutz 2022-12-28 13:24:05 +01:00
parent 309af499f6
commit d943498eaa
2 changed files with 10 additions and 8 deletions

View File

@ -2,7 +2,7 @@ APPNAME, CATEGORY, APPID
"7-Zip", "file tool", "XPDNKVCX4QD2DC" "7-Zip", "file tool", "XPDNKVCX4QD2DC"
"Aquile Reader", "ebook reader", "9P08T4JLTQNK" "Aquile Reader", "ebook reader", "9P08T4JLTQNK"
"CrystalDiskInfo", "HDD/SSD tool", "XP8K4RGX25G3GM" "CrystalDiskInfo", "HDD/SSD tool", "XP8K4RGX25G3GM"
"Google Chrome", " desktop browser", "Google.Chrome" "Google Chrome", "desktop browser", "Google.Chrome"
"Dopamine", "audio player", "Digimezzo.Dopamine.2" "Dopamine", "audio player", "Digimezzo.Dopamine.2"
"Dropbox", "file sync", "Dropbox.Dropbox" "Dropbox", "file sync", "Dropbox.Dropbox"
"Git for Windows", "code management", "Git.Git" "Git for Windows", "code management", "Git.Git"

1 APPNAME CATEGORY APPID
2 7-Zip file tool XPDNKVCX4QD2DC
3 Aquile Reader ebook reader 9P08T4JLTQNK
4 CrystalDiskInfo HDD/SSD tool XP8K4RGX25G3GM
5 Google Chrome desktop browser desktop browser Google.Chrome
6 Dopamine audio player Digimezzo.Dopamine.2
7 Dropbox file sync Dropbox.Dropbox
8 Git for Windows code management Git.Git

View File

@ -15,31 +15,33 @@
try { try {
$StopWatch = [system.diagnostics.stopwatch]::startNew() $StopWatch = [system.diagnostics.stopwatch]::startNew()
"⏳ Step 1 - Loading table from Data/basic-apps.csv..." "⏳ Step 1 - Loading Data/basic-apps.csv..."
$Table = Import-CSV "$PSScriptRoot/../Data/basic-apps.csv" $Table = Import-CSV "$PSScriptRoot/../Data/basic-apps.csv"
$NumEntries = $Table.count $NumEntries = $Table.count
Write-Host " About to install $NumEntries apps: " -NoNewline Write-Host " The following $NumEntries basic apps will be installed or upgraded: " -NoNewline
foreach($Row in $Table) { foreach($Row in $Table) {
[string]$AppName = $Row.AppName [string]$AppName = $Row.AppName
Write-Host "$AppName, " -NoNewline Write-Host "$AppName, " -NoNewline
} }
"" ""
"Press <Control> <C> to abort, otherwise the installation will start..." "Press <Control> <C> to abort, otherwise the installation will start in 10 seconds..."
sleep -s 3 sleep -s 10
[int]$Step = 2 [int]$Step = 2
[int]$Failed = 0
foreach($Row in $Table) { foreach($Row in $Table) {
[string]$AppName = $Row.AppName [string]$AppName = $Row.AppName
[string]$Category = $Row.Category [string]$Category = $Row.Category
[string]$AppID = $Row.AppID [string]$AppID = $Row.AppID
"Step $Step/$($NumEntries + 1) - Installing $AppName ($Category)..." "($Step/$($NumEntries + 1)) Installing $AppName ($Category)..."
& winget install --id $AppID --accept-package-agreements --accept-source-agreements & winget install --id $AppID --accept-package-agreements --accept-source-agreements
if ($lastExitCode -ne "0") { throw "'winget install' for $AppName failed" } if ($lastExitCode -ne "0") { Write-Warning "'winget install' for $AppName failed"; $Failed++ }
$Step++ $Step++
} }
[int]$Installed = ($NumEntries - $Failed)
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ installed $NumEntries apps in $Elapsed sec" "✔️ installed $Installed basic apps in $Elapsed sec. ($Failed failed)"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"