dofiles-win/Documents/PowerShell/installed-apps.ps1

28 lines
1.1 KiB
PowerShell
Raw Permalink Normal View History

2024-02-10 23:21:21 -04:00
function sortScoopOutput($scoop) {
$ht = ConvertFrom-Json -AsHashtable -InputObject $scoop
$od = [ordered]@{}
# Structure of json is object with a key name and the value as an array of objects, which each have 4 key value pairs
# Sort the keys and the array of objects, as well the key value pairs in the objects
foreach ($key in $ht.Keys | Sort-Object) {
$od[$key] = @()
foreach ($app in $ht[$key] | Sort-Object) {
$app = $app | Sort-Object
$od[$key] += [ordered]@{}
foreach ($k in $app.Keys | Sort-Object) {
$od[$key][-1][$k] = $app[$k]
}
}
# Sort the array by the name key
# NOTE: This property is hard coded, and could be changed if scoop changes the json structure
$od[$key] = $od[$key] | Sort-Object -Property name
}
$json = ConvertTo-Json -InputObject $od
$json_string = $json -join "`n"
return $json_string
}
# Scoop installed apps
2024-02-15 17:02:50 -04:00
# sortScoopOutput($(scoop export)) | Out-File "~\scoop\apps.json"
scoop export | Out-File "~\scoop\apps.json"
2024-02-10 23:21:21 -04:00
# Pipx installed apps
pipx list --json | Out-File "~\.pipx.json"