mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-02-17 16:06:59 +00:00
45 lines
1.4 KiB
PowerShell
45 lines
1.4 KiB
PowerShell
# Read Apps.json and return list of app objects with optional filtering
|
|
function LoadAppsDetailsFromJson {
|
|
param (
|
|
[switch]$OnlyInstalled,
|
|
[string]$InstalledList = "",
|
|
[switch]$InitialCheckedFromJson
|
|
)
|
|
|
|
$apps = @()
|
|
try {
|
|
$jsonContent = Get-Content -Path $script:AppsListFilePath -Raw | ConvertFrom-Json
|
|
}
|
|
catch {
|
|
Write-Error "Failed to read Apps.json: $_"
|
|
return $apps
|
|
}
|
|
|
|
foreach ($appData in $jsonContent.Apps) {
|
|
$appId = $appData.AppId.Trim()
|
|
if ($appId.length -eq 0) { continue }
|
|
|
|
if ($OnlyInstalled) {
|
|
if (-not ($InstalledList -like ("*$appId*")) -and -not (Get-AppxPackage -Name $appId)) {
|
|
continue
|
|
}
|
|
if (($appId -eq "Microsoft.Edge") -and -not ($InstalledList -like "* Microsoft.Edge *")) {
|
|
continue
|
|
}
|
|
}
|
|
|
|
$displayName = if ($appData.FriendlyName) { "$($appData.FriendlyName) ($appId)" } else { $appId }
|
|
$isChecked = if ($InitialCheckedFromJson) { $appData.SelectedByDefault } else { $false }
|
|
|
|
$apps += [PSCustomObject]@{
|
|
AppId = $appId
|
|
DisplayName = $displayName
|
|
IsChecked = $isChecked
|
|
Description = $appData.Description
|
|
SelectedByDefault = $appData.SelectedByDefault
|
|
}
|
|
}
|
|
|
|
return $apps
|
|
}
|