From 8e265e7c5c7b22f7dda493a3cf753ff9b671d932 Mon Sep 17 00:00:00 2001 From: Isaac Shoebottom Date: Sat, 10 Feb 2024 23:21:21 -0400 Subject: [PATCH] Add installed apps script --- Documents/PowerShell/installed-apps.ps1 | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Documents/PowerShell/installed-apps.ps1 diff --git a/Documents/PowerShell/installed-apps.ps1 b/Documents/PowerShell/installed-apps.ps1 new file mode 100644 index 0000000..2ba0348 --- /dev/null +++ b/Documents/PowerShell/installed-apps.ps1 @@ -0,0 +1,27 @@ +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 +sortScoopOutput($(scoop export)) | Out-File "~\scoop\apps.json" +# Pipx installed apps +pipx list --json | Out-File "~\.pipx.json" \ No newline at end of file