wingetautoupdate/Sources/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1

60 lines
2.1 KiB
PowerShell
Raw Normal View History

2023-03-31 15:56:07 +00:00
#Function to get the Block List apps
2022-04-13 16:50:06 +00:00
function Get-ExcludedApps {
2024-03-15 09:39:51 +00:00
$AppIDs = @()
2024-09-01 13:13:47 +00:00
#blacklist in registry
if ($GPOList) {
2024-09-01 13:13:47 +00:00
Write-ToLog "-> Excluded apps from GPO is activated"
if (Test-Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList") {
$ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList").Property
foreach ($ValueName in $ValueNames) {
$AppIDs += (Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList" -Name $ValueName).Trim()
}
2024-09-01 13:13:47 +00:00
Write-ToLog "-> Successsfully loaded excluded apps list."
}
2024-03-15 09:39:51 +00:00
2024-09-01 13:12:10 +00:00
}
2024-09-01 13:13:47 +00:00
#blacklist pulled from URI
2024-03-15 09:39:51 +00:00
elseif ($URIList) {
$RegPath = "$WAU_GPORoot";
$RegValueName = 'WAU_URIList';
2024-09-01 13:12:10 +00:00
2024-03-15 09:39:51 +00:00
if (Test-Path -Path $RegPath) {
$RegKey = Get-Item -Path $RegPath;
$WAUURI = $RegKey.GetValue($RegValueName);
2024-09-01 13:13:47 +00:00
Write-ToLog "-> Excluded apps from URI is activated"
2024-03-15 09:39:51 +00:00
if ($null -ne $WAUURI) {
$resp = Invoke-WebRequest -Uri $WAUURI -UseDefaultCredentials;
if ($resp.BaseResponse.StatusCode -eq [System.Net.HttpStatusCode]::OK) {
2024-09-01 13:12:10 +00:00
$resp.Content.Split([System.Environment]::NewLine, [System.StringSplitOptions]::RemoveEmptyEntries) |
2024-03-15 09:39:51 +00:00
ForEach-Object {
$AppIds += $_
}
2024-09-01 13:13:47 +00:00
Write-ToLog "-> Successsfully loaded excluded apps list."
2024-03-15 09:39:51 +00:00
}
}
}
}
2024-09-01 13:13:47 +00:00
#blacklist pulled from local file
elseif (Test-Path "$WorkingDir\excluded_apps.txt") {
2024-09-01 13:54:36 +00:00
$AppIDs = (Get-Content -Path "$WorkingDir\excluded_apps.txt").Trim()
2024-09-01 13:13:47 +00:00
Write-ToLog "-> Successsfully loaded local excluded apps list."
}
#blacklist pulled from default file
elseif (Test-Path "$WorkingDir\config\default_excluded_apps.txt") {
2024-09-01 13:54:36 +00:00
$AppIDs = (Get-Content -Path "$WorkingDir\config\default_excluded_apps.txt").Trim()
2024-09-01 13:13:47 +00:00
Write-ToLog "-> Successsfully loaded default excluded apps list."
}
2024-03-15 09:39:51 +00:00
return $AppIDs | Where-Object { $_.length -gt 0 }
2024-09-01 13:54:36 +00:00
}