2023-10-31 12:20:46 +01:00
|
|
|
|
<#
|
2022-08-21 11:04:59 +02:00
|
|
|
|
.SYNOPSIS
|
|
|
|
|
Installs basic apps
|
|
|
|
|
.DESCRIPTION
|
2023-02-19 10:51:25 +01:00
|
|
|
|
This PowerShell script installs basic Windows apps such as browser, e-mail client, etc.
|
2023-07-22 09:09:18 +02:00
|
|
|
|
NOTE: Apps from Microsoft Store are preferred (due to security and automatic updates).
|
2022-08-21 11:04:59 +02:00
|
|
|
|
.EXAMPLE
|
2023-08-06 21:35:36 +02:00
|
|
|
|
PS> ./install-basic-apps.ps1
|
2023-07-22 09:09:18 +02:00
|
|
|
|
⏳ (1/37) Loading Data/basic-apps.csv... 35 apps
|
|
|
|
|
⏳ (2/37) These apps will be installed or upgraded: 7-Zip · Aquile Reader ...
|
2022-08-21 11:04:59 +02:00
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
.NOTES
|
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
|
|
|
|
|
2023-07-22 09:09:18 +02:00
|
|
|
|
Write-Host "⏳ (1/37) Loading Data/basic-apps.csv... " -noNewline
|
2023-10-31 11:25:11 +01:00
|
|
|
|
$Table = Import-CSV "$PSScriptRoot/../data/basic-apps.csv"
|
2022-08-21 11:04:59 +02:00
|
|
|
|
$NumEntries = $Table.count
|
2023-05-16 14:22:01 +02:00
|
|
|
|
"$NumEntries apps"
|
2023-07-22 09:09:18 +02:00
|
|
|
|
Write-Host "⏳ (2/37) These apps will be installed or upgraded: " -noNewline
|
2022-08-29 11:55:06 +02:00
|
|
|
|
foreach($Row in $Table) {
|
2023-02-19 10:51:25 +01:00
|
|
|
|
[string]$AppName = $Row.APPLICATION
|
2023-06-16 15:47:02 +02:00
|
|
|
|
Write-Host "$AppName · " -noNewline
|
2022-08-29 11:55:06 +02:00
|
|
|
|
}
|
|
|
|
|
""
|
2023-05-16 14:22:01 +02:00
|
|
|
|
""
|
2023-06-16 15:47:02 +02:00
|
|
|
|
"Installation will start in 15 seconds... (otherwise press <Control> <C> to abort)"
|
2023-05-01 19:32:25 +02:00
|
|
|
|
Start-Sleep -seconds 15
|
2022-08-21 11:04:59 +02:00
|
|
|
|
|
2023-05-01 19:32:25 +02:00
|
|
|
|
[int]$Step = 3
|
2023-08-04 12:15:05 +02:00
|
|
|
|
[int]$Skipped = 0
|
2022-08-21 11:04:59 +02:00
|
|
|
|
foreach($Row in $Table) {
|
2023-02-19 10:51:25 +01:00
|
|
|
|
[string]$AppName = $Row.APPLICATION
|
|
|
|
|
[string]$Category = $Row.CATEGORY
|
|
|
|
|
[string]$AppID = $Row.APPID
|
2023-05-01 19:32:25 +02:00
|
|
|
|
Write-Host " "
|
|
|
|
|
Write-Host "⏳ ($Step/$($NumEntries + 2)) Installing $Category '$AppName'..."
|
2022-08-21 11:04:59 +02:00
|
|
|
|
& winget install --id $AppID --accept-package-agreements --accept-source-agreements
|
2023-08-04 12:15:05 +02:00
|
|
|
|
if ($lastExitCode -ne "0") { $Skipped++ }
|
2022-08-21 11:04:59 +02:00
|
|
|
|
$Step++
|
|
|
|
|
}
|
2023-08-04 12:15:05 +02:00
|
|
|
|
[int]$Installed = ($NumEntries - $Skipped)
|
2022-08-21 11:04:59 +02:00
|
|
|
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
2023-08-04 12:15:05 +02:00
|
|
|
|
"✔️ Installation of $Installed basic apps ($Skipped skipped) took $Elapsed sec"
|
2022-08-21 11:04:59 +02:00
|
|
|
|
exit 0 # success
|
|
|
|
|
} catch {
|
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
|
|
|
exit 1
|
2023-02-19 10:51:25 +01:00
|
|
|
|
}
|