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

51 lines
1.6 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 = @()
#region blacklist in registry
if ($GPOList) {
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-03-15 09:39:51 +00:00
2024-09-01 13:12:10 +00:00
}
2024-03-15 09:39:51 +00:00
#endregion blacklist in registry
#region blacklist pulled from URI
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);
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-03-15 09:39:51 +00:00
#endregion blacklist pulled from URI
elseif (Test-Path "$WorkingDir\excluded_apps.txt") {
return (Get-Content -Path "$WorkingDir\excluded_apps.txt").Trim() | Where-Object { $_.length -gt 0 }
}
2024-03-15 09:39:51 +00:00
return $AppIDs | Where-Object { $_.length -gt 0 }
2022-09-25 14:54:58 +00:00
}