PowerShell/Docs/install-basic-apps.md

87 lines
2.6 KiB
Markdown
Raw Normal View History

2023-07-29 09:55:25 +02:00
## Script: *install-basic-apps.ps1*
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
## Parameters
```powershell
2023-07-29 09:45:37 +02:00
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.
```
## Example
```powershell
PS> ./install-basic-apps
2023-07-29 09:45:37 +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-11-17 19:46:02 +01:00
```
## Notes
Author: Markus Fleschutz | License: CC0
## Related Links
https://github.com/fleschutz/PowerShell
2023-07-29 09:55:25 +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
PS> ./install-basic-apps
2023-07-29 09:45:37 +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-11-17 20:02:26 +01:00
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
2023-07-29 09:45:37 +02:00
Write-Host "⏳ (1/37) Loading Data/basic-apps.csv... " -noNewline
2022-11-17 20:02:26 +01:00
$Table = Import-CSV "$PSScriptRoot/../Data/basic-apps.csv"
$NumEntries = $Table.count
2023-05-26 12:20:18 +02:00
"$NumEntries apps"
2023-07-29 09:45:37 +02:00
Write-Host "⏳ (2/37) These apps will be installed or upgraded: " -noNewline
2022-11-17 20:02:26 +01:00
foreach($Row in $Table) {
2023-05-26 12:20:18 +02:00
[string]$AppName = $Row.APPLICATION
2023-07-29 09:45:37 +02:00
Write-Host "$AppName · " -noNewline
2022-11-17 20:02:26 +01:00
}
""
2023-05-26 12:20:18 +02:00
""
2023-07-29 09:45:37 +02:00
"Installation will start in 15 seconds... (otherwise 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
2023-05-26 12:20:18 +02:00
[int]$Step = 3
[int]$Failed = 0
2022-11-17 20:02:26 +01:00
foreach($Row in $Table) {
2023-05-26 12:20:18 +02:00
[string]$AppName = $Row.APPLICATION
[string]$Category = $Row.CATEGORY
[string]$AppID = $Row.APPID
Write-Host " "
Write-Host "⏳ ($Step/$($NumEntries + 2)) Installing $Category '$AppName'..."
2022-11-17 20:02:26 +01:00
& winget install --id $AppID --accept-package-agreements --accept-source-agreements
2023-05-26 12:20:18 +02:00
if ($lastExitCode -ne "0") { $Failed++ }
2022-11-17 20:02:26 +01:00
$Step++
}
2023-05-26 12:20:18 +02:00
[int]$Installed = ($NumEntries - $Failed)
2022-11-17 20:02:26 +01:00
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
2023-07-29 09:45:37 +02:00
"✔️ installed $Installed of $NumEntries basic apps 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
2023-07-29 09:55:25 +02:00
*(generated by convert-ps2md.ps1 using the comment-based help of install-basic-apps.ps1 as of 07/29/2023 09:55:11)*