PowerShell/Scripts/check-apps.ps1

35 lines
895 B
PowerShell
Raw Normal View History

2022-12-02 11:48:59 +01:00
<#
.SYNOPSIS
2023-01-06 11:40:42 +01:00
Query app details
2022-12-02 11:48:59 +01:00
.DESCRIPTION
This PowerShell script queries application details and list it.
2022-12-02 11:48:59 +01:00
.EXAMPLE
PS> ./check-apps
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
if ($IsLinux) {
# TODO
} else {
2023-01-01 19:22:35 +01:00
Write-Progress "⏳ Querying installed apps..."
2022-12-28 18:21:43 +01:00
$Apps = Get-AppxPackage
[int]$NumInstalled = $Apps.Count
2023-01-06 11:40:42 +01:00
[int]$NumNonOk = 0
foreach($App in $Apps) { if ($App.Status -ne "Ok") { $NumNonOk++ } }
2022-12-04 19:07:18 +01:00
2023-01-01 19:22:35 +01:00
Write-Progress "⏳ Querying available updates..."
2022-12-28 18:21:43 +01:00
$NumUpdates = (winget upgrade --include-unknown).Count - 5
[int]$NumErrors = (Get-AppxLastError)
2023-01-06 11:40:42 +01:00
Write-Host "$NumInstalled apps ($NumNonOk non-ok, $NumErrors errors, $NumUpdates updates available)"
2023-01-01 19:22:35 +01:00
Write-Progress -Completed " "
}
2022-12-02 11:48:59 +01:00
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}