mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-08 17:14:28 +01:00
42 lines
972 B
PowerShell
Executable File
42 lines
972 B
PowerShell
Executable File
<#
|
|
.SYNOPSIS
|
|
install-updates.ps1
|
|
.DESCRIPTION
|
|
Install updates on the local machhine (needs admin rights)
|
|
.EXAMPLE
|
|
PS> ./install-updates
|
|
.NOTES
|
|
Author: Markus Fleschutz · License: CC0
|
|
.LINK
|
|
https://github.com/fleschutz/PowerShell
|
|
#>
|
|
|
|
#Requires -RunAsAdministrator
|
|
|
|
try {
|
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
|
|
|
if ($IsLinux) {
|
|
"⏳ Step 1/4: Fetching update infos for installed Debian packages..."
|
|
& sudo apt update
|
|
|
|
"⏳ Step 2/4: Upgrading installed Debian packages..."
|
|
& sudo apt upgrade --yes
|
|
|
|
"⏳ Step 3/4: Removing obsolete Debian packages..."
|
|
& sudo apt autoremove --yes
|
|
|
|
"⏳ Step 4/4: Upgrading installed Snap packages..."
|
|
& sudo snap refresh
|
|
} else {
|
|
"Sorry, not supported yet"
|
|
}
|
|
|
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
|
"✔️ installed updates in $Elapsed sec"
|
|
exit 0 # success
|
|
} catch {
|
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
|
exit 1
|
|
}
|