Implement "Get-Installed" (quick-and-dirty)

This commit is contained in:
Marterich 2024-08-22 22:50:52 +02:00
parent d111244347
commit 579030eeb9
2 changed files with 20 additions and 8 deletions

View File

@ -13,6 +13,16 @@ Function Invoke-WinUtilCurrentSystem {
param( param(
$CheckBox $CheckBox
) )
if ($CheckBox -eq "choco"){
$apps = (choco list | Select-String -Pattern "^\S+").Matches.Value
$filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "WPFInstall*"}
$sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter} | ForEach-Object {
$dependencies = @($sync.configs.applications.$($psitem.Key).choco -split ";")
if ($dependencies -in $apps) {
Write-Output $psitem.name
}
}
}
if ($checkbox -eq "winget") { if ($checkbox -eq "winget") {

View File

@ -16,14 +16,12 @@ function Invoke-WPFGetInstalled {
return return
} }
if(((Test-WinUtilPackageManager -winget) -eq "not-installed") -and $checkbox -eq "winget") { if(($sync.WPFpreferChocolatey.IsChecked -eq $false) -and ((Test-WinUtilPackageManager -winget) -eq "not-installed") -and $checkbox -eq "winget") {
return return
} }
if ($sync.WPFpreferChocolatey.IsChecked) { $preferChoco = $sync.WPFpreferChocolatey.IsChecked
Write-Host "The Function `"Get Installed`" is only supported for Winget at the moment" -ForegroundColor Red Invoke-WPFRunspace -ArgumentList $checkbox, $preferChoco -DebugPreference $DebugPreference -ScriptBlock {
} param($checkbox, $preferChoco, $DebugPreference)
Invoke-WPFRunspace -ArgumentList $checkbox -DebugPreference $DebugPreference -ScriptBlock {
param($checkbox, $DebugPreference)
$sync.ProcessRunning = $true $sync.ProcessRunning = $true
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" }) $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" })
@ -34,8 +32,12 @@ function Invoke-WPFGetInstalled {
if($checkbox -eq "tweaks") { if($checkbox -eq "tweaks") {
Write-Host "Getting Installed Tweaks..." Write-Host "Getting Installed Tweaks..."
} }
if ($preferChoco -and $checkbox -eq "winget") {
$Checkboxes = Invoke-WinUtilCurrentSystem -CheckBox $checkbox $Checkboxes = Invoke-WinUtilCurrentSystem -CheckBox "choco"
}
else{
$Checkboxes = Invoke-WinUtilCurrentSystem -CheckBox $checkbox
}
$sync.form.Dispatcher.invoke({ $sync.form.Dispatcher.invoke({
foreach($checkbox in $Checkboxes) { foreach($checkbox in $Checkboxes) {