From 8379e72f868790dac8a5d17bbc5bcf8d484a5911 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sun, 1 Sep 2024 15:54:36 +0200 Subject: [PATCH] clean --- .../functions/Get-ExcludedApps.ps1 | 6 ++--- .../functions/Get-IncludedApps.ps1 | 22 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Sources/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 b/Sources/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 index bd5deed..a81ceda 100644 --- a/Sources/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 +++ b/Sources/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 @@ -43,17 +43,17 @@ function Get-ExcludedApps { #blacklist pulled from local file elseif (Test-Path "$WorkingDir\excluded_apps.txt") { - $AppIDs = (Get-Content -Path "$WorkingDir\excluded_apps.txt").Trim() | Where-Object { $_.length -gt 0 } + $AppIDs = (Get-Content -Path "$WorkingDir\excluded_apps.txt").Trim() Write-ToLog "-> Successsfully loaded local excluded apps list." } #blacklist pulled from default file elseif (Test-Path "$WorkingDir\config\default_excluded_apps.txt") { - $AppIDs = (Get-Content -Path "$WorkingDir\config\default_excluded_apps.txt").Trim() | Where-Object { $_.length -gt 0 } + $AppIDs = (Get-Content -Path "$WorkingDir\config\default_excluded_apps.txt").Trim() Write-ToLog "-> Successsfully loaded default excluded apps list." } return $AppIDs | Where-Object { $_.length -gt 0 } -} \ No newline at end of file +} diff --git a/Sources/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 b/Sources/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 index 950cede..2474edd 100644 --- a/Sources/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 +++ b/Sources/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 @@ -3,45 +3,47 @@ function Get-IncludedApps { $AppIDs = @() - #region whitelist in registry + #whitelist in registry if ($GPOList) { + Write-ToLog "-> Included apps from GPO is activated" if (Test-Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList") { $ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList").Property - foreach ($ValueName in $ValueNames) { $AppIDs += (Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList" -Name $ValueName).Trim() } - + Write-ToLog "-> Successsfully loaded included apps list." } - } - #endregion whitelist in registry - #region whitelist pulled from URI + } + #whitelist pulled from URI elseif ($URIList) { $RegPath = "$WAU_GPORoot"; $RegValueName = 'WAU_URIList'; - + if (Test-Path -Path $RegPath) { $RegKey = Get-Item -Path $RegPath; $WAUURI = $RegKey.GetValue($RegValueName); + Write-ToLog "-> Included apps from URI is activated" if ($null -ne $WAUURI) { $resp = Invoke-WebRequest -Uri $WAUURI -UseDefaultCredentials; if ($resp.BaseResponse.StatusCode -eq [System.Net.HttpStatusCode]::OK) { - $resp.Content.Split([System.Environment]::NewLine, [System.StringSplitOptions]::RemoveEmptyEntries) | + $resp.Content.Split([System.Environment]::NewLine, [System.StringSplitOptions]::RemoveEmptyEntries) | ForEach-Object { $AppIds += $_ } + Write-ToLog "-> Successsfully loaded included apps list." } } } } - #endregion whitelist pulled from URI + #whitelist pulled from local file elseif (Test-Path "$WorkingDir\included_apps.txt") { - return (Get-Content -Path "$WorkingDir\included_apps.txt").Trim() | Where-Object { $_.length -gt 0 } + $AppIDs = (Get-Content -Path "$WorkingDir\included_apps.txt").Trim() + Write-ToLog "-> Successsfully loaded local included apps list." }