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

51 lines
1.6 KiB
PowerShell
Raw Normal View History

#Function to get the allow List apps
function Get-IncludedApps {
2024-03-15 09:39:51 +00:00
$AppIDs = @()
2024-03-15 09:39:51 +00:00
#region whitelist in registry
if ($GPOList) {
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()
}
}
2024-03-15 09:39:51 +00:00
}
#endregion whitelist in registry
#region 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);
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) |
ForEach-Object {
$AppIds += $_
}
}
}
}
}
2024-03-15 09:39:51 +00:00
#endregion whitelist pulled from URI
elseif (Test-Path "$WorkingDir\included_apps.txt") {
return (Get-Content -Path "$WorkingDir\included_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
}