mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-05-09 10:04:45 +02:00
Update install-basic-apps.ps1
This commit is contained in:
parent
309af499f6
commit
d943498eaa
@ -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"
|
||||||
|
|
@ -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])"
|
||||||
|
Loading…
Reference in New Issue
Block a user