mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-06-02 08:25:42 +02:00
Improved install-updates.ps1
This commit is contained in:
parent
5f2db88dc3
commit
e3672038e5
@ -9,7 +9,7 @@
|
|||||||
Specifies the minimum level in bytes (10GB by default)
|
Specifies the minimum level in bytes (10GB by default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./check-drive-space.ps1 C
|
PS> ./check-drive-space.ps1 C
|
||||||
✅ Drive C: uses 56% of 1TB - 442GB free
|
✅ Drive C: uses 56% of 1TB: 442GB free
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -49,7 +49,7 @@ try {
|
|||||||
Write-Host "⚠️ Drive $driveName with $(Bytes2String $total) is nearly full, $(Bytes2String $free) free"
|
Write-Host "⚠️ Drive $driveName with $(Bytes2String $total) is nearly full, $(Bytes2String $free) free"
|
||||||
} else {
|
} else {
|
||||||
[int64]$percent = ($used * 100) / $total
|
[int64]$percent = ($used * 100) / $total
|
||||||
Write-Host "✅ Drive $driveName uses $percent% of $(Bytes2String $total) - $(Bytes2String $free) free"
|
Write-Host "✅ Drive $driveName uses $percent% of $(Bytes2String $total): $(Bytes2String $free) free"
|
||||||
}
|
}
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -55,7 +55,7 @@ try {
|
|||||||
Write-Output "✅ Swap space has $(MB2String $total) reserved."
|
Write-Output "✅ Swap space has $(MB2String $total) reserved."
|
||||||
} else {
|
} else {
|
||||||
[int64]$percent = ($used * 100) / $total
|
[int64]$percent = ($used * 100) / $total
|
||||||
Write-Output "✅ Swap space at $(MB2String $used) ($percent%) of $(MB2String $total)."
|
Write-Output "✅ Swap space uses $percent% of $(MB2String $total): $(MB2String $free) free"
|
||||||
}
|
}
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -7,11 +7,10 @@
|
|||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./install-updates.ps1
|
PS> ./install-updates.ps1
|
||||||
⏳ (1/2) Checking update requirements...
|
⏳ (1/2) Checking update requirements...
|
||||||
✅ Drive C: has 441 GB free (56% of 1TB used)
|
✅ Drive C: uses 56% of 1TB: 441GB free
|
||||||
✅ Swap space has 1GB free (2% of 1GB used)
|
✅ Swap space uses 22% of 4GB: 3GB free
|
||||||
✅ No pending system reboot
|
|
||||||
|
|
||||||
⏳ (2/2) Updating Microsoft Store apps...
|
⏳ (2/2) Checking Microsoft Store for updates...
|
||||||
...
|
...
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
@ -28,7 +27,6 @@ try {
|
|||||||
& "$PSScriptRoot/check-smart-devices.ps1"
|
& "$PSScriptRoot/check-smart-devices.ps1"
|
||||||
& "$PSScriptRoot/check-drive-space.ps1" /
|
& "$PSScriptRoot/check-drive-space.ps1" /
|
||||||
& "$PSScriptRoot/check-swap-space.ps1"
|
& "$PSScriptRoot/check-swap-space.ps1"
|
||||||
& "$PSScriptRoot/check-pending-reboot.ps1"
|
|
||||||
Start-Sleep -seconds 3
|
Start-Sleep -seconds 3
|
||||||
""
|
""
|
||||||
"⏳ (2/5) Querying latest package information..."
|
"⏳ (2/5) Querying latest package information..."
|
||||||
@ -52,24 +50,24 @@ try {
|
|||||||
& "$PSScriptRoot/check-smart-devices.ps1"
|
& "$PSScriptRoot/check-smart-devices.ps1"
|
||||||
& "$PSScriptRoot/check-drive-space.ps1" C
|
& "$PSScriptRoot/check-drive-space.ps1" C
|
||||||
& "$PSScriptRoot/check-swap-space.ps1"
|
& "$PSScriptRoot/check-swap-space.ps1"
|
||||||
& "$PSScriptRoot/check-pending-reboot.ps1"
|
|
||||||
Start-Sleep -seconds 3
|
Start-Sleep -seconds 3
|
||||||
""
|
""
|
||||||
"⏳ (2/4) Updating Microsoft Store apps..."
|
"⏳ (2/4) Checking Microsoft Store for updates..."
|
||||||
if (Get-Command winget -errorAction SilentlyContinue) {
|
if (Get-Command winget -errorAction SilentlyContinue) {
|
||||||
& winget upgrade --all --source=msstore --include-unknown
|
& winget upgrade --all --source=msstore --include-unknown
|
||||||
}
|
}
|
||||||
""
|
""
|
||||||
"⏳ (3/4) Updating WinGet Store apps..."
|
"⏳ (3/4) Checking WinGet for updates..."
|
||||||
if (Get-Command winget -errorAction SilentlyContinue) {
|
if (Get-Command winget -errorAction SilentlyContinue) {
|
||||||
& winget upgrade --all --source=winget --include-unknown
|
& winget upgrade --all --source=winget --include-unknown
|
||||||
}
|
}
|
||||||
""
|
""
|
||||||
"⏳ (4/4) Updating Chocolatey packages..."
|
"⏳ (4/4) Checking Chocolatey for updates..."
|
||||||
if (Get-Command choco -errorAction SilentlyContinue) {
|
if (Get-Command choco -errorAction SilentlyContinue) {
|
||||||
& choco upgrade all -y
|
& choco upgrade all -y
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
& "$PSScriptRoot/check-pending-reboot.ps1"
|
||||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||||
"✅ Updates installed in $($elapsed)s."
|
"✅ Updates installed in $($elapsed)s."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
|
Loading…
x
Reference in New Issue
Block a user