Update list-updates.ps1 and install-updates.ps1

This commit is contained in:
Markus Fleschutz 2023-09-18 08:21:30 +02:00
parent 48caeda15f
commit 77f9dafecf
2 changed files with 12 additions and 12 deletions

View File

@ -1,9 +1,9 @@
<# <#
.SYNOPSIS .SYNOPSIS
Installs updates Installs software updates
.DESCRIPTION .DESCRIPTION
This PowerShell script installs software updates for the local machine (needs admin rights). This PowerShell script installs software updates for the local machine (needs admin rights).
Use the script 'list-updates.ps1' to list available updates. NOTE: Use the script 'list-updates.ps1' to list the latest software updates.
.EXAMPLE .EXAMPLE
PS> ./install-updates.ps1 PS> ./install-updates.ps1
.LINK .LINK
@ -32,12 +32,12 @@ try {
& sudo softwareupdate -i -a & sudo softwareupdate -i -a
Write-Progress -completed " " Write-Progress -completed " "
} else { } else {
Write-Progress "⏳ Installing updates..." Write-Progress "⏳ Installing updates from winget and Microsoft Store..."
& winget upgrade --all & winget upgrade --all --include-unknown
Write-Progress -completed " " Write-Progress -completed " "
} }
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"Updates installed in $Elapsed sec" "Installed updates in $Elapsed sec"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -1,9 +1,9 @@
<# <#
.SYNOPSIS .SYNOPSIS
Lists new software updates Lists software updates
.DESCRIPTION .DESCRIPTION
This PowerShell script queries and lists available software updates for the local machine. This PowerShell script queries the latest available software updates for the local machine and lists it.
Use 'install-updates.ps1' to install the listed updates. NOTE: Use the script 'install-updates.ps1' to install the listed updates.
.EXAMPLE .EXAMPLE
PS> ./list-updates.ps1 PS> ./list-updates.ps1
@ -25,12 +25,12 @@ try {
"⏳ (2/2) Querying Snap updates..." "⏳ (2/2) Querying Snap updates..."
& sudo snap refresh --list & sudo snap refresh --list
} else { } else {
Write-Progress "⏳ Querying the latest updates from winget and Microsoft Store..."
" " " "
Write-Progress "⏳ Querying new software updates..." & winget upgrade --include-unknown
& winget upgrade Write-Progress -completed " "
Write-Progress -completed "."
} }
"(use 'install-updates.ps1' to install the listed updates)" " (use 'install-updates.ps1' to install the listed updates)"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"