PowerShell/docs/install-basic-apps.md
2024-03-27 17:36:59 +01:00

97 lines
2.8 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Script: *install-basic-apps.ps1*
========================
This PowerShell script installs basic Windows apps such as browser, e-mail client, etc.
NOTE: Apps from Microsoft Store are preferred (due to security and automatic updates).
Parameters
----------
```powershell
PS> ./install-basic-apps.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
Example
-------
```powershell
PS> ./install-basic-apps.ps1
(1) Loading data/basic-apps.csv... 37 apps listed
(2) Applications to install/upgrade: 7-Zip · Aquile Reader ...
...
Installed 37 basic apps (0 skipped) in 387 sec.
```
Notes
-----
Author: Markus Fleschutz | License: CC0
Related Links
-------------
https://github.com/fleschutz/PowerShell
Script Content
--------------
```powershell
<#
.SYNOPSIS
Installs basic apps
.DESCRIPTION
This PowerShell script installs basic Windows apps such as browser, e-mail client, etc.
NOTE: Apps from Microsoft Store are preferred (due to security and automatic updates).
.EXAMPLE
PS> ./install-basic-apps.ps1
⏳ (1) Loading data/basic-apps.csv... 37 apps listed
⏳ (2) Applications to install/upgrade: 7-Zip · Aquile Reader ...
...
✔️ Installed 37 basic apps (0 skipped) in 387 sec.
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
$stopWatch = [system.diagnostics.stopwatch]::startNew()
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
}
""
""
"The installation will start in 15 seconds or press <Control> <C> to abort..."
Start-Sleep -seconds 15
[int]$step = 3
[int]$numSkipped = 0
foreach($row in $table) {
[string]$appName = $row.APPLICATION
[string]$category = $row.CATEGORY
[string]$appID = $row.APPID
Write-Host " "
Write-Host "⏳ ($step/$($numEntries + 2)) Installing $category '$appName'..."
& winget install --id $appID --accept-package-agreements --accept-source-agreements
if ($lastExitCode -ne "0") { $numSkipped++ }
$step++
}
[int]$numInstalled = ($numEntries - $numSkipped)
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
"✔️ Installed $numInstalled basic apps ($numSkipped skipped) in $elapsed sec."
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
```
*(generated by convert-ps2md.ps1 using the comment-based help of install-basic-apps.ps1 as of 03/27/2024 17:36:26)*