mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-13 06:27:16 +02:00
Updated install-basic-apps.ps1
This commit is contained in:
@ -6,10 +6,11 @@
|
|||||||
NOTE: Apps from Microsoft Store are preferred (due to security and automatic updates).
|
NOTE: Apps from Microsoft Store are preferred (due to security and automatic updates).
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./install-basic-apps.ps1
|
PS> ./install-basic-apps.ps1
|
||||||
⏳ (1) Loading data/basic-apps.csv... 37 apps listed
|
⏳ (1) Loading basic-apps.csv from data/ folder...
|
||||||
⏳ (2) Applications to install/upgrade: 7-Zip · Aquile Reader ...
|
⏳ (2) Will install/upgrade 39 basic apps: 7-Zip, Aquile Reader ...
|
||||||
|
NOTE: Installation starts in 15 seconds or press <Control> <C> to abort...
|
||||||
...
|
...
|
||||||
✅ Installed 37 basic apps (0 skipped) in 387 sec.
|
✅ 39 basic apps installed (0 skipped, took 387s)
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -21,18 +22,16 @@
|
|||||||
try {
|
try {
|
||||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
|
|
||||||
Write-Host "⏳ (1) Loading data/basic-apps.csv... " -noNewline
|
Write-Host "⏳ (1) Loading basic-apps.csv from data/ folder..."
|
||||||
$table = Import-CSV "$PSScriptRoot/../data/basic-apps.csv"
|
$table = Import-CSV "$PSScriptRoot/../data/basic-apps.csv"
|
||||||
$numEntries = $table.count
|
$numEntries = $table.count
|
||||||
"$numEntries apps listed"
|
Write-Host "⏳ (2) Will install/upgrade $numEntries basic apps: " -noNewline
|
||||||
Write-Host "⏳ (2) Applications to install/upgrade: " -noNewline
|
|
||||||
foreach($row in $table) {
|
foreach($row in $table) {
|
||||||
[string]$appName = $row.APPLICATION
|
[string]$appName = $row.APPLICATION
|
||||||
Write-Host "$appName · " -noNewline
|
Write-Host "$appName, " -noNewline
|
||||||
}
|
}
|
||||||
""
|
""
|
||||||
""
|
"NOTE: Installation starts in 15 seconds or press <Control> <C> to abort..."
|
||||||
"The installation will start in 15 seconds or press <Control> <C> to abort..."
|
|
||||||
Start-Sleep -seconds 15
|
Start-Sleep -seconds 15
|
||||||
|
|
||||||
[int]$step = 3
|
[int]$step = 3
|
||||||
@ -43,13 +42,13 @@ try {
|
|||||||
[string]$appID = $row.APPID
|
[string]$appID = $row.APPID
|
||||||
Write-Host " "
|
Write-Host " "
|
||||||
Write-Host "⏳ ($step/$($numEntries + 2)) Installing $category '$appName'..."
|
Write-Host "⏳ ($step/$($numEntries + 2)) Installing $category '$appName'..."
|
||||||
& winget install --id $appID --accept-package-agreements --accept-source-agreements
|
& winget install --id $appID --silent --accept-package-agreements --accept-source-agreements
|
||||||
if ($lastExitCode -ne 0) { $numSkipped++ }
|
if ($lastExitCode -ne 0) { $numSkipped++ }
|
||||||
$step++
|
$step++
|
||||||
}
|
}
|
||||||
[int]$numInstalled = ($numEntries - $numSkipped)
|
[int]$numInstalled = ($numEntries - $numSkipped)
|
||||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||||
"✅ Installed $numInstalled basic apps ($numSkipped skipped) in $elapsed sec."
|
"✅ $numInstalled basic apps installed ($numSkipped skipped, took $($elapsed)s)"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||||
|
Reference in New Issue
Block a user