mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-06-10 23:16:55 +02:00
Update install-updates.ps1
This commit is contained in:
parent
830e211cd4
commit
b5909b519a
@ -2,10 +2,14 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Installs software 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 (might need admin rights).
|
||||||
NOTE: Use the script 'list-updates.ps1' to list the latest software updates.
|
NOTE: Use the script 'list-updates.ps1' to list the latest software updates before.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./install-updates.ps1
|
PS> ./install-updates.ps1
|
||||||
|
⏳ (1/2) Checking drive space...
|
||||||
|
✅ Drive C: uses 56%, 441GB free of 999GB
|
||||||
|
⏳ (2/2) Installing updates from winget and Microsoft Store...
|
||||||
|
...
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,7 +17,7 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
|
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
"⏳ (1/5) Checking drive space..."
|
"⏳ (1/5) Checking drive space..."
|
||||||
@ -35,12 +39,15 @@ try {
|
|||||||
& sudo softwareupdate -i -a
|
& sudo softwareupdate -i -a
|
||||||
Write-Progress -completed " "
|
Write-Progress -completed " "
|
||||||
} else {
|
} else {
|
||||||
Write-Progress "⏳ Installing updates from winget and Microsoft Store..."
|
"⏳ (1/2) Checking drive space..."
|
||||||
|
& "$PSScriptRoot/check-drive-space.ps1" C
|
||||||
|
|
||||||
|
"⏳ (2/2) Installing updates from winget and Microsoft Store..."
|
||||||
|
""
|
||||||
& winget upgrade --all --include-unknown
|
& winget upgrade --all --include-unknown
|
||||||
Write-Progress -completed " "
|
|
||||||
}
|
}
|
||||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||||
"✅ Installed updates 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])"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user