2022-12-04 10:40:18 +01:00
|
|
|
## The *check-apps.ps1* Script
|
|
|
|
|
2023-05-26 12:20:18 +02:00
|
|
|
This PowerShell script queries the application status and prints it.
|
2022-12-04 10:40:18 +01:00
|
|
|
|
|
|
|
## Parameters
|
|
|
|
```powershell
|
2023-05-26 12:20:18 +02:00
|
|
|
/home/mf/Repos/PowerShell/Scripts/check-apps.ps1 [<CommonParameters>]
|
2022-12-04 10:40:18 +01:00
|
|
|
|
|
|
|
[<CommonParameters>]
|
|
|
|
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
|
|
|
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
|
|
|
```
|
|
|
|
|
|
|
|
## Example
|
|
|
|
```powershell
|
|
|
|
PS> ./check-apps
|
2023-05-26 12:20:18 +02:00
|
|
|
✅ 119 apps installed, 11 upgrades available
|
2022-12-04 10:40:18 +01:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
## Notes
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
|
|
|
|
## Related Links
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
|
|
|
## Source Code
|
|
|
|
```powershell
|
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
2023-05-26 12:20:18 +02:00
|
|
|
Query the app status
|
2022-12-04 10:40:18 +01:00
|
|
|
.DESCRIPTION
|
2023-05-26 12:20:18 +02:00
|
|
|
This PowerShell script queries the application status and prints it.
|
2022-12-04 10:40:18 +01:00
|
|
|
.EXAMPLE
|
|
|
|
PS> ./check-apps
|
2023-05-26 12:20:18 +02:00
|
|
|
✅ 119 apps installed, 11 upgrades available
|
2022-12-04 10:40:18 +01:00
|
|
|
.LINK
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
.NOTES
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
#>
|
|
|
|
|
|
|
|
try {
|
|
|
|
if ($IsLinux) {
|
|
|
|
# TODO
|
|
|
|
} else {
|
2023-05-26 12:20:18 +02:00
|
|
|
Write-Progress "⏳ Querying installed apps and updates..."
|
|
|
|
$Apps = Get-AppxPackage
|
|
|
|
$Status = "✅ $($Apps.Count) apps installed"
|
|
|
|
|
|
|
|
[int]$NumNonOk = 0
|
|
|
|
foreach($App in $Apps) { if ($App.Status -ne "Ok") { $NumNonOk++ } }
|
|
|
|
if ($NumNonOk -gt 0) { $Status += ", $NumNonOk non-ok" }
|
|
|
|
[int]$NumErrors = (Get-AppxLastError)
|
|
|
|
if ($NumErrors -gt 0) { $Status += ", $NumErrors errors" }
|
|
|
|
|
|
|
|
$NumUpdates = (winget upgrade --include-unknown).Count - 5
|
|
|
|
Write-Progress -Completed "."
|
|
|
|
Write-Host "$Status, $NumUpdates upgrades available"
|
2022-12-04 10:40:18 +01:00
|
|
|
}
|
|
|
|
exit 0 # success
|
|
|
|
} catch {
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
*Generated by convert-ps2md.ps1 using the comment-based help of check-apps.ps1*
|