forked from fleschutz/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-updates.ps1
More file actions
executable file
·42 lines (37 loc) · 1 KB
/
Copy pathinstall-updates.ps1
File metadata and controls
executable file
·42 lines (37 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<#
.SYNOPSIS
Installs software updates
.DESCRIPTION
This PowerShell script installs updates for the local machine (needs admin rights).
.EXAMPLE
PS> ./install-updates
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
if ($IsLinux) {
"⏳ (1/4) Querying updates for installed Debian packages..."
& sudo apt update
"⏳ (2/4) Upgrading installed Debian packages..."
& sudo apt upgrade --yes
"⏳ (3/4) Removing obsolete Debian packages..."
& sudo apt autoremove --yes
"⏳ (4/4) Upgrading installed Snap packages..."
& sudo snap refresh
} else {
"⏳ (1/2) Querying application updates..."
& winget upgrade
" "
"⏳ (2/2) Upgrading applications..."
& winget upgrade --all
}
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✅ updates installed in $Elapsed sec."
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}