2023-03-31 15:56:07 +00:00
|
|
|
#Function to get the Block List apps
|
2022-04-13 16:50:06 +00:00
|
|
|
|
2023-10-03 08:18:00 +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
|
2023-10-03 08:18:00 +00:00
|
|
|
if ($GPOList) {
|
|
|
|
|
2024-09-01 13:13:47 +00:00
|
|
|
Write-ToLog "-> Excluded apps from GPO is activated"
|
2023-10-03 08:18:00 +00:00
|
|
|
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) {
|
2024-03-08 12:01:29 +00:00
|
|
|
$AppIDs += (Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList" -Name $ValueName).Trim()
|
2023-01-20 02:59:27 +00:00
|
|
|
}
|
2024-09-01 13:13:47 +00:00
|
|
|
Write-ToLog "-> Successsfully loaded excluded apps list."
|
2023-10-03 08:18:00 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-10-03 08:18:00 +00:00
|
|
|
|
|
|
|
}
|
2024-09-01 13:13:47 +00:00
|
|
|
#blacklist pulled from local file
|
2023-10-03 08:18:00 +00:00
|
|
|
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."
|
2023-10-03 08:18:00 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-03-15 09:39:51 +00:00
|
|
|
return $AppIDs | Where-Object { $_.length -gt 0 }
|
2024-09-01 13:54:36 +00:00
|
|
|
}
|