2024-11-08 12:38:20 +01:00
|
|
|
The *install-basic-apps.ps1* Script
|
|
|
|
===========================
|
2022-11-17 19:46:02 +01:00
|
|
|
|
2023-05-26 12:20:18 +02:00
|
|
|
This PowerShell script installs basic Windows apps such as browser, e-mail client, etc.
|
2023-07-29 09:45:37 +02:00
|
|
|
NOTE: Apps from Microsoft Store are preferred (due to security and automatic updates).
|
2022-11-17 19:46:02 +01:00
|
|
|
|
2023-07-29 10:04:38 +02:00
|
|
|
Parameters
|
|
|
|
----------
|
2022-11-17 19:46:02 +01:00
|
|
|
```powershell
|
2024-11-08 12:35:11 +01:00
|
|
|
/home/markus/Repos/PowerShell/scripts/install-basic-apps.ps1 [<CommonParameters>]
|
2022-11-17 19:46:02 +01:00
|
|
|
|
|
|
|
[<CommonParameters>]
|
|
|
|
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
|
|
|
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
|
|
|
```
|
|
|
|
|
2023-07-29 10:04:38 +02:00
|
|
|
Example
|
|
|
|
-------
|
2022-11-17 19:46:02 +01:00
|
|
|
```powershell
|
2023-08-06 21:36:33 +02:00
|
|
|
PS> ./install-basic-apps.ps1
|
2024-01-25 13:31:10 +01:00
|
|
|
⏳ (1) Loading data/basic-apps.csv... 37 apps listed
|
|
|
|
⏳ (2) Applications to install/upgrade: 7-Zip · Aquile Reader ...
|
|
|
|
...
|
2024-11-08 12:35:11 +01:00
|
|
|
✅ Installed 37 basic apps (0 skipped) in 387 sec.
|
2022-11-17 19:46:02 +01:00
|
|
|
|
|
|
|
```
|
|
|
|
|
2023-07-29 10:04:38 +02:00
|
|
|
Notes
|
|
|
|
-----
|
2022-11-17 19:46:02 +01:00
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
|
2023-07-29 10:04:38 +02:00
|
|
|
Related Links
|
|
|
|
-------------
|
2022-11-17 19:46:02 +01:00
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
2023-07-29 10:04:38 +02:00
|
|
|
Script Content
|
|
|
|
--------------
|
2022-11-17 20:05:34 +01:00
|
|
|
```powershell
|
2022-11-17 20:02:26 +01:00
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
|
|
Installs basic apps
|
|
|
|
.DESCRIPTION
|
2023-05-26 12:20:18 +02:00
|
|
|
This PowerShell script installs basic Windows apps such as browser, e-mail client, etc.
|
2023-07-29 09:45:37 +02:00
|
|
|
NOTE: Apps from Microsoft Store are preferred (due to security and automatic updates).
|
2022-11-17 20:02:26 +01:00
|
|
|
.EXAMPLE
|
2023-08-06 21:36:33 +02:00
|
|
|
PS> ./install-basic-apps.ps1
|
2024-01-25 13:31:10 +01:00
|
|
|
⏳ (1) Loading data/basic-apps.csv... 37 apps listed
|
|
|
|
⏳ (2) Applications to install/upgrade: 7-Zip · Aquile Reader ...
|
|
|
|
...
|
2024-11-08 12:35:11 +01:00
|
|
|
✅ Installed 37 basic apps (0 skipped) in 387 sec.
|
2022-11-17 20:02:26 +01:00
|
|
|
.LINK
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
.NOTES
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
#>
|
|
|
|
|
|
|
|
try {
|
2024-01-25 13:31:10 +01:00
|
|
|
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
2022-11-17 20:02:26 +01:00
|
|
|
|
2024-01-25 13:31:10 +01:00
|
|
|
Write-Host "⏳ (1) Loading data/basic-apps.csv... " -noNewline
|
|
|
|
$table = Import-CSV "$PSScriptRoot/../data/basic-apps.csv"
|
|
|
|
$numEntries = $table.count
|
|
|
|
"$numEntries apps listed"
|
|
|
|
Write-Host "⏳ (2) Applications to install/upgrade: " -noNewline
|
|
|
|
foreach($row in $table) {
|
|
|
|
[string]$appName = $row.APPLICATION
|
|
|
|
Write-Host "$appName · " -noNewline
|
2022-11-17 20:02:26 +01:00
|
|
|
}
|
|
|
|
""
|
2023-05-26 12:20:18 +02:00
|
|
|
""
|
2024-01-25 13:31:10 +01:00
|
|
|
"The installation will start in 15 seconds or press <Control> <C> to abort..."
|
2023-05-26 12:20:18 +02:00
|
|
|
Start-Sleep -seconds 15
|
2022-11-17 20:02:26 +01:00
|
|
|
|
2024-01-25 13:31:10 +01:00
|
|
|
[int]$step = 3
|
|
|
|
[int]$numSkipped = 0
|
|
|
|
foreach($row in $table) {
|
|
|
|
[string]$appName = $row.APPLICATION
|
|
|
|
[string]$category = $row.CATEGORY
|
|
|
|
[string]$appID = $row.APPID
|
2023-05-26 12:20:18 +02:00
|
|
|
Write-Host " "
|
2024-01-25 13:31:10 +01:00
|
|
|
Write-Host "⏳ ($step/$($numEntries + 2)) Installing $category '$appName'..."
|
|
|
|
& winget install --id $appID --accept-package-agreements --accept-source-agreements
|
|
|
|
if ($lastExitCode -ne "0") { $numSkipped++ }
|
|
|
|
$step++
|
2022-11-17 20:02:26 +01:00
|
|
|
}
|
2024-01-25 13:31:10 +01:00
|
|
|
[int]$numInstalled = ($numEntries - $numSkipped)
|
|
|
|
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
2024-11-08 12:35:11 +01:00
|
|
|
"✅ Installed $numInstalled basic apps ($numSkipped skipped) in $elapsed sec."
|
2022-11-17 20:02:26 +01:00
|
|
|
exit 0 # success
|
|
|
|
} catch {
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
|
|
exit 1
|
|
|
|
}
|
2022-11-17 20:05:34 +01:00
|
|
|
```
|
2022-11-17 20:02:26 +01:00
|
|
|
|
2024-11-20 11:52:20 +01:00
|
|
|
*(generated by convert-ps2md.ps1 as of 11/20/2024 11:51:54)*
|