Improved check-power.ps1 and install-updates.ps1

This commit is contained in:
Markus Fleschutz 2025-02-26 20:44:10 +01:00
parent 5390e1fa70
commit a0f0ed7814
2 changed files with 14 additions and 4 deletions

View File

@ -29,7 +29,7 @@ try {
} elseif ($percent -ge 95) {
$reply = "✅ Battery full ($percent%, power scheme is '$powerScheme')"
} else {
$reply = "✅ Battery charging ($percent%, power scheme is '$powerScheme')"
$reply = "✅ Battery $percent% and charging (power scheme is '$powerScheme')"
}
} else { # must be offline
if (($remaining -eq 0) -and ($percent -ge 60)) {

View File

@ -55,10 +55,20 @@ try {
& "$PSScriptRoot/check-pending-reboot.ps1"
Start-Sleep -seconds 3
""
"⏳ (2/2) Installing updates from winget..."
"⏳ (2/4) Updating Windows Store apps..."
if (Get-Command winget -ErrorAction SilentlyContinue) {
& winget upgrade --all --source=msstore --include-unknown
}
""
& winget upgrade --all --source=winget
# & winget upgrade --all --source=msstore # does not work
"⏳ (3/4) Updating Chocolatey packages..."
if (Get-Command choco -ErrorAction SilentlyContinue) {
& choco upgrade all -y
}
""
"⏳ (4/4) Updating Winget packages..."
if (Get-Command winget -ErrorAction SilentlyContinue) {
& winget upgrade --all --source=winget --include-unknown
}
}
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
"✅ Updates installed in $($elapsed)s."