2021-09-27 10:38:12 +02:00
|
|
|
|
<#
|
2021-09-17 16:14:05 +02:00
|
|
|
|
.SYNOPSIS
|
2023-07-10 10:37:15 +02:00
|
|
|
|
Installs updates
|
2021-09-17 16:14:05 +02:00
|
|
|
|
.DESCRIPTION
|
2023-07-10 10:37:15 +02:00
|
|
|
|
This PowerShell script installs software updates for the local machine (needs admin rights).
|
|
|
|
|
Use the script 'list-updates.ps1' to list available updates.
|
2021-09-17 16:14:05 +02:00
|
|
|
|
.EXAMPLE
|
2021-09-24 17:19:49 +02:00
|
|
|
|
PS> ./install-updates
|
2021-09-17 16:14:05 +02:00
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
2022-01-29 12:47:46 +01:00
|
|
|
|
.NOTES
|
2022-09-06 21:42:04 +02:00
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
2021-09-17 16:14:05 +02:00
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
|
|
|
|
|
|
|
|
|
if ($IsLinux) {
|
2022-11-14 22:00:21 +01:00
|
|
|
|
"⏳ (1/4) Querying updates for installed Debian packages..."
|
2021-09-28 16:28:53 +02:00
|
|
|
|
& sudo apt update
|
2021-09-17 16:21:19 +02:00
|
|
|
|
|
2022-11-03 12:19:50 +01:00
|
|
|
|
"⏳ (2/4) Upgrading installed Debian packages..."
|
2021-09-29 08:18:28 +02:00
|
|
|
|
& sudo apt upgrade --yes
|
2021-09-17 16:21:19 +02:00
|
|
|
|
|
2022-11-03 12:19:50 +01:00
|
|
|
|
"⏳ (3/4) Removing obsolete Debian packages..."
|
2021-09-29 08:18:28 +02:00
|
|
|
|
& sudo apt autoremove --yes
|
2021-09-17 16:21:19 +02:00
|
|
|
|
|
2022-11-03 12:19:50 +01:00
|
|
|
|
"⏳ (4/4) Upgrading installed Snap packages..."
|
2021-09-28 16:28:53 +02:00
|
|
|
|
& sudo snap refresh
|
2021-09-17 16:14:05 +02:00
|
|
|
|
} else {
|
2023-04-16 10:35:00 +02:00
|
|
|
|
Write-Progress "⏳ Installing updates..."
|
2022-11-18 19:19:52 +01:00
|
|
|
|
" "
|
2022-10-03 23:00:59 +02:00
|
|
|
|
& winget upgrade --all
|
2023-04-16 10:35:00 +02:00
|
|
|
|
Write-Progress -completed " "
|
2021-09-17 16:14:05 +02:00
|
|
|
|
}
|
|
|
|
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
2023-07-10 10:37:15 +02:00
|
|
|
|
"✅ installed the updates in $Elapsed sec"
|
2021-09-27 10:09:45 +02:00
|
|
|
|
exit 0 # success
|
2021-09-17 16:14:05 +02:00
|
|
|
|
} catch {
|
2022-04-13 12:06:32 +02:00
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
2021-09-17 16:14:05 +02:00
|
|
|
|
exit 1
|
2022-09-17 13:12:39 +02:00
|
|
|
|
}
|