using a default blacklist instead

pull/678/head
Romain 2024-09-01 15:13:47 +02:00
parent 2eac70cc64
commit 8c0c94cc4e
1 changed files with 17 additions and 8 deletions

View File

@ -4,21 +4,20 @@ function Get-ExcludedApps {
$AppIDs = @() $AppIDs = @()
#region blacklist in registry #blacklist in registry
if ($GPOList) { if ($GPOList) {
Write-ToLog "-> Excluded apps from GPO is activated"
if (Test-Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList") { if (Test-Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList") {
$ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList").Property $ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList").Property
foreach ($ValueName in $ValueNames) { foreach ($ValueName in $ValueNames) {
$AppIDs += (Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList" -Name $ValueName).Trim() $AppIDs += (Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList" -Name $ValueName).Trim()
} }
Write-ToLog "-> Successsfully loaded excluded apps list."
} }
} }
#endregion blacklist in registry #blacklist pulled from URI
#region blacklist pulled from URI
elseif ($URIList) { elseif ($URIList) {
$RegPath = "$WAU_GPORoot"; $RegPath = "$WAU_GPORoot";
@ -27,6 +26,7 @@ function Get-ExcludedApps {
if (Test-Path -Path $RegPath) { if (Test-Path -Path $RegPath) {
$RegKey = Get-Item -Path $RegPath; $RegKey = Get-Item -Path $RegPath;
$WAUURI = $RegKey.GetValue($RegValueName); $WAUURI = $RegKey.GetValue($RegValueName);
Write-ToLog "-> Excluded apps from URI is activated"
if ($null -ne $WAUURI) { if ($null -ne $WAUURI) {
$resp = Invoke-WebRequest -Uri $WAUURI -UseDefaultCredentials; $resp = Invoke-WebRequest -Uri $WAUURI -UseDefaultCredentials;
if ($resp.BaseResponse.StatusCode -eq [System.Net.HttpStatusCode]::OK) { if ($resp.BaseResponse.StatusCode -eq [System.Net.HttpStatusCode]::OK) {
@ -34,17 +34,26 @@ function Get-ExcludedApps {
ForEach-Object { ForEach-Object {
$AppIds += $_ $AppIds += $_
} }
Write-ToLog "-> Successsfully loaded excluded apps list."
} }
} }
} }
} }
#endregion blacklist pulled from URI #blacklist pulled from local file
elseif (Test-Path "$WorkingDir\excluded_apps.txt") { elseif (Test-Path "$WorkingDir\excluded_apps.txt") {
return (Get-Content -Path "$WorkingDir\excluded_apps.txt").Trim() | Where-Object { $_.length -gt 0 } $AppIDs = (Get-Content -Path "$WorkingDir\excluded_apps.txt").Trim() | Where-Object { $_.length -gt 0 }
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 }
Write-ToLog "-> Successsfully loaded default excluded apps list."
} }
return $AppIDs | Where-Object { $_.length -gt 0 } return $AppIDs | Where-Object { $_.length -gt 0 }
} }